]> git.ipfire.org Git - thirdparty/lldpd.git/blob - .github/workflows/ci.yml
006c683fdce5305573dbd1e3aa7c2176928c28e0
[thirdparty/lldpd.git] / .github / workflows / ci.yml
1 ---
2 name: CI
3 on:
4 push:
5 branches:
6 - master
7 tags:
8 - 1.*
9 pull_request:
10 schedule:
11 - cron: 0 7 1 * *
12 jobs:
13 build-linux:
14 runs-on: ubuntu-latest
15 strategy:
16 matrix:
17 config-args:
18 - "--with-embedded-libevent"
19 - "--disable-shared --enable-static"
20 - "--disable-privsep --with-snmp"
21 - "--with-snmp --disable-lldpmed --disable-dot1 --disable-dot3 --disable-custom"
22 - "--enable-oldies"
23 - "--enable-dtrace"
24 - "--with-seccomp"
25 compiler:
26 - gcc
27 release:
28 - false
29 include:
30 - config-args: ''
31 release: true
32 - compiler: clang
33 config-args: "--without-snmp --with-xml"
34 steps:
35 - uses: actions/checkout@v4
36 with:
37 submodules: true
38 - name: Unshallow repository
39 if: matrix.release
40 run: |
41 git fetch --tags
42 git fetch --unshallow
43 - name: Install stuff
44 run: ./tests/ci/install.sh
45 - name: Build and run tests
46 run: ./tests/ci/run.sh
47 env:
48 LLDPD_CONFIG_ARGS: ${{ matrix.config-args }}
49 LLDPD_RELEASE: ${{ matrix.release }}
50 CC: ${{ matrix.compiler }}
51 - name: Generate release body
52 if: matrix.release
53 run: ./tests/ci/release.sh build > ./release.md
54 - name: Upload release tarball
55 uses: actions/upload-artifact@v3
56 if: matrix.release
57 with:
58 name: tarball
59 path: build/lldpd-*.tar.gz
60 if-no-files-found: error
61 - name: Upload release summary
62 uses: actions/upload-artifact@v3
63 if: matrix.release
64 with:
65 name: release
66 path: release.md
67 if-no-files-found: error
68
69 build-macos:
70 runs-on: macos-latest
71 strategy:
72 matrix:
73 include:
74 - config-args: "--without-snmp --with-xml"
75 release: false
76 - config-args: >
77 --prefix=/usr/local
78 --localstatedir=/var
79 --sysconfdir=/private/etc
80 --with-embedded-libevent
81 --without-snmp
82 --without-xml
83 release: true
84 steps:
85 - uses: actions/checkout@v4
86 with:
87 submodules: true
88 - name: Install stuff
89 run: ./tests/ci/install.sh
90 - name: Build and run tests
91 run: ./tests/ci/run.sh
92 env:
93 LLDPD_CONFIG_ARGS: ${{ matrix.config-args }}
94 CC: clang
95 - name: Upload MacOS release package
96 uses: actions/upload-artifact@v3
97 if: matrix.release
98 with:
99 name: package
100 path: build/lldpd-*.pkg
101 if-no-files-found: error
102
103 build-bsd:
104 timeout-minutes: 20
105 strategy:
106 fail-fast: false
107 matrix:
108 os:
109 - name: freebsd
110 version: '13.0'
111 runner: macos-latest
112 - name: openbsd
113 version: '7.1'
114 runner: macos-latest
115 runs-on: ${{ matrix.os.runner }}
116 steps:
117 - uses: actions/checkout@v4
118 with:
119 submodules: true
120 - name: Test on ${{ matrix.os.name }}
121 uses: cross-platform-actions/action@v0.19.0
122 with:
123 operating_system: ${{ matrix.os.name }}
124 version: ${{ matrix.os.version }}
125 environment_variables: LLDPD_CONFIG_ARGS
126 shell: bash
127 run: |
128 set -e
129 ./tests/ci/install.sh
130 ./tests/ci/run.sh
131
132 docker:
133 needs:
134 - build-linux
135 - build-macos
136 - build-bsd
137 runs-on: ubuntu-latest
138 name: Build Docker images
139 if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
140 steps:
141 - uses: actions/checkout@v4
142 - uses: docker/setup-qemu-action@v2
143 - uses: docker/setup-buildx-action@v2
144 - uses: docker/metadata-action@v4
145 id: meta
146 with:
147 images: |
148 ghcr.io/lldpd/lldpd
149 tags: |
150 type=schedule,pattern=master
151 type=ref,event=branch
152 type=semver,pattern={{version}}
153 type=semver,pattern={{major}}.{{minor}}
154 type=semver,pattern={{major}}
155 - uses: docker/login-action@v2
156 with:
157 registry: ghcr.io
158 username: ${{ github.repository_owner }}
159 password: ${{ secrets.GITHUB_TOKEN }}
160 - uses: docker/build-push-action@v4
161 with:
162 context: .
163 file: Dockerfile
164 platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64,linux/arm/v6' || 'linux/amd64' }}
165 push: true
166 tags: ${{ steps.meta.outputs.tags }}
167 labels: ${{ steps.meta.outputs.labels }}
168
169 release:
170 needs:
171 - docker
172 runs-on: ubuntu-latest
173 name: Publish release
174 if: startsWith(github.ref, 'refs/tags/')
175 steps:
176 - name: Download TGZ tarball
177 uses: actions/download-artifact@v3
178 with:
179 name: tarball
180 - name: Download MacOS package
181 uses: actions/download-artifact@v3
182 with:
183 name: package
184 - name: Download release text
185 uses: actions/download-artifact@v3
186 with:
187 name: release
188 - name: Publish release
189 uses: softprops/action-gh-release@v1
190 with:
191 body_path: release.md
192 draft: true
193 files: |
194 *.tar.gz
195 *.pkg
196 env:
197 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}