@@ -8,6 +8,12 @@ concurrency:
88 group : ${{ github.workflow }}-${{ github.ref }}
99 cancel-in-progress : true
1010
11+ env :
12+ SQLX_OFFLINE : " 1"
13+ # sccache
14+ SCCACHE_GHA_ENABLED : " true"
15+ RUSTC_WRAPPER : " sccache"
16+
1117jobs :
1218 build-docker-release :
1319 # Ignore tags with -, like v1.0.0-alpha
@@ -45,41 +51,26 @@ jobs:
4551 steps :
4652 - name : Create GitHub release
4753 id : release
48- uses : softprops/action-gh-release@v2
49- if : startsWith(github.ref, 'refs/tags/')
54+ uses : shogo82148/actions-create-release@v1
5055 with :
5156 draft : true
5257 generate_release_notes : true
5358
5459 create-sbom :
55- needs : [create-release, build-docker-release]
60+ needs :
61+ - create-release
62+ - build-docker-release
5663 uses : ./.github/workflows/sbom.yml
5764 with :
5865 upload_url : ${{ needs.create-release.outputs.upload_url }}
5966
6067 build-binaries :
61- needs : [create-release]
68+ needs :
69+ - create-release
6270 runs-on :
6371 - self-hosted
64- - ${{ matrix.os }}
72+ - Linux
6573 - X64
66- strategy :
67- fail-fast : false
68- matrix :
69- build : [linux, linux-arm64, freebsd]
70- include :
71- - build : linux
72- arch : amd64
73- os : Linux
74- target : x86_64-unknown-linux-gnu
75- - build : linux-arm64
76- arch : arm64
77- os : Linux
78- target : aarch64-unknown-linux-gnu
79- - build : freebsd
80- arch : amd64
81- os : Linux
82- target : x86_64-unknown-freebsd
8374 steps :
8475 # Store the version, stripping any v-prefix
8576 - name : Write release version
@@ -93,104 +84,177 @@ jobs:
9384 with :
9485 submodules : recursive
9586
87+ - name : Install NodeJS
88+ uses : actions/setup-node@v6
89+ with :
90+ node-version : 25
91+
92+ - name : Install pnpm
93+ uses : pnpm/action-setup@v6
94+ with :
95+ cache : true
96+ version : 10
97+
98+ # Change to '--frozen-lockfile' once this gets fixed:
99+ # https://github.com/pnpm/action-setup/issues/40
100+ - name : Build frontend
101+ run : pnpm install --ignore-scripts --no-frozen-lockfile && pnpm build
102+ working-directory : web
103+
96104 - name : Install Rust stable
97- uses : actions-rs/ toolchain@v1
105+ uses : dtolnay/rust- toolchain@stable
98106 with :
99- toolchain : 1.89.0 # "stable" causes rust-lld: error on aarch64-linux target: ${{ matrix.target }}
100- override : true
107+ targets : " aarch64-unknown-linux-gnu"
101108
102- - name : Setup `packer`
103- uses : hashicorp/setup-packer@main
104- id : setup
109+ - name : Run sccache-cache
110+ uses : mozilla-actions/sccache-action@v0.0.9
105111
106- - name : Set up Docker BuildX
107- uses : docker/setup-buildx-action@v4
112+ - name : Build Linux x86_64 binary
113+ run : |
114+ cargo build --locked --release --target x86_64-unknown-linux-gnu
115+ mv target/x86_64-unknown-linux-gnu/release/defguard-proxy defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu
116+ tar -zcf defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz \
117+ defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu
118+
119+ - name : Build Linux aarch64 binary
120+ env :
121+ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER : aarch64-linux-gnu-gcc
122+ PKG_CONFIG_SYSROOT_DIR : /usr/lib/aarch64-linux-gnu
123+ run : |
124+ cargo build --locked --release --target aarch64-unknown-linux-gnu
125+ mv target/aarch64-unknown-linux-gnu/release/defguard-proxy defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu
126+ tar -zcf defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz \
127+ defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu
128+
129+ - name : Build FreeBSD binary
130+ run : |
131+ rsync -rlptxzH -e 'ssh -l root' --del ./ freebsd:work/
132+ ssh root@freebsd 'cd work && cargo build --locked --release'
133+ scp root@freebsd:work/target/release/defguard-proxy defguard-proxy-${{ env.VERSION }}-x86_64-unknown-freebsd
134+ tar -zcf defguard-proxy-${{ env.VERSION }}-x86_64-unknown-freebsd.tar.gz \
135+ defguard-proxy-${{ env.VERSION }}-x86_64-unknown-freebsd
136+
137+ - name : Build x86_64 DEB package
138+ uses : defGuard/fpm-action@main
108139 with :
109- config-inline : |
110- [registry."docker.io"]
111- mirrors = ["dockerhub-proxy.teonite.net"]
140+ fpm_args :
141+ " defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu=/usr/bin/defguard-proxy
142+ defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
143+ example-config.toml=/etc/defguard/proxy.toml"
144+ fpm_opts : " --architecture amd64 --output-type deb --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.deb"
112145
113- - name : Install pnpm
114- uses : pnpm/action-setup@v4
146+ - name : Build aarch64 DEB package
147+ uses : defGuard/fpm-action@main
115148 with :
116- # FIXME: temporarily pinned because of https://github.com/pnpm/pnpm/pull/9959
117- version : 10.17
149+ fpm_args :
150+ " defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu=/usr/bin/defguard-proxy
151+ defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
152+ example-config.toml=/etc/defguard/proxy.toml"
153+ fpm_opts : " --architecture arm64 --output-type deb --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu.deb"
118154
119- - name : Use Node.js
120- uses : actions/setup-node@v6
155+ - name : Build x86_64 RPM package
156+ uses : defGuard/fpm-action@main
121157 with :
122- node-version : 25
123- cache : " pnpm"
124- cache-dependency-path : ./web/pnpm-lock.yaml
158+ fpm_args :
159+ " defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu=/usr/bin/defguard-proxy
160+ defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
161+ example-config.toml=/etc/defguard/proxy.toml"
162+ fpm_opts : " --architecture amd64 --output-type rpm --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.rpm"
125163
126- - name : Install frontend dependencies
127- run : pnpm install --ignore-scripts --frozen-lockfile
128- working-directory : web
164+ - name : Build aarch64 RPM package
165+ uses : defGuard/fpm-action@main
166+ with :
167+ fpm_args :
168+ " defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu=/usr/bin/defguard-proxy
169+ defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service
170+ example-config.toml=/etc/defguard/proxy.toml"
171+ fpm_opts : " --architecture arm64 --output-type rpm --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-aarch64-unknown-freebsd.rpm"
129172
130- - name : Build frontend
131- run : pnpm build
132- working-directory : web
173+ - name : Build FreeBSD package
174+ uses : defGuard/fpm-action@main
175+ with :
176+ fpm_args :
177+ " defguard-proxy-${{ env.VERSION }}-x86_64-unknown-freebsd=/usr/local/bin/defguard-proxy
178+ defguard-proxy.service.freebsd=/usr/local/etc/rc.d/defguard-proxy
179+ example-config.toml=/etc/defguard/proxy.toml"
180+ fpm_opts : " --architecture amd64 --output-type freebsd --version ${{ env.VERSION }} --package defguard-${{ env.VERSION }}_x86_64-unknown-freebsd.pkg --freebsd-osversion '*' --depends openssl"
133181
134- - name : Build release binary
135- uses : actions-rs/cargo@v1
182+ - name : Upload Linux x86_64 archive
183+ uses : shogo82148/actions-upload-release-asset@v1
184+ env :
185+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
136186 with :
137- use-cross : true
138- command : build
139- args : --locked --release --target ${{ matrix.target }}
187+ upload_url : ${{ needs.create-release.outputs.upload_url }}
188+ asset_path : defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz
189+ asset_content_type : application/gzip
190+ overwrite : true
140191
141- - name : Rename binary
142- run : mv target/${{ matrix.target }}/release/defguard-proxy defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}
192+ - name : Upload Linux aarch64 archive
193+ uses : shogo82148/actions-upload-release-asset@v1
194+ env :
195+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
196+ with :
197+ upload_url : ${{ needs.create-release.outputs.upload_url }}
198+ asset_path : defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz
199+ asset_content_type : application/gzip
200+ overwrite : true
143201
144- - name : Tar
145- uses : a7ul/tar-action@v1.2.0
202+ - name : Upload FreeBSD x86_64 archive
203+ uses : shogo82148/actions-upload-release-asset@v1
204+ env :
205+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
146206 with :
147- command : c
148- files : |
149- defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}
150- outPath : defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
207+ upload_url : ${{ needs.create-release.outputs.upload_url }}
208+ asset_path : defguard-proxy-${{ env.VERSION }}-x86_64-unknown-freebsd.tar.gz
209+ asset_content_type : application/gzip
210+ overwrite : true
151211
152- - name : Upload release archive
153- uses : actions/ upload-release-asset@v1.0.2
212+ - name : Upload Linux x86_64 DEB
213+ uses : shogo82148/actions- upload-release-asset@v1
154214 env :
155215 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
156216 with :
157217 upload_url : ${{ needs.create-release.outputs.upload_url }}
158- asset_path : defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
159- asset_name : defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
160- asset_content_type : application/octet-stream
218+ asset_path : defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.deb
219+ asset_content_type : application/gzip
220+ overwrite : true
161221
162- - name : Build DEB package
163- if : matrix.build == 'linux'
164- uses : bpicode/github-action-fpm@master
222+ - name : Upload Linux aarch64 DEB
223+ uses : shogo82148/actions-upload-release-asset@v1
224+ env :
225+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
165226 with :
166- fpm_args : " defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}=/usr/bin/defguard-proxy defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service example-config.toml=/etc/defguard/proxy.toml"
167- fpm_opts : " --architecture ${{ matrix.arch }} --debug --output-type deb --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-${{ matrix.target }}.deb"
227+ upload_url : ${{ needs.create-release.outputs.upload_url }}
228+ asset_path : defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu.deb
229+ asset_content_type : application/gzip
230+ overwrite : true
168231
169- - name : Upload DEB
170- if : matrix.build == 'linux'
171- uses : actions/upload-release-asset@v1.0.2
232+ - name : Upload Linux x86_64 RPM
233+ uses : shogo82148/actions-upload-release-asset@v1
172234 env :
173235 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
174236 with :
175237 upload_url : ${{ needs.create-release.outputs.upload_url }}
176- asset_path : defguard-proxy-${{ env.VERSION }}-${{ matrix.target }}.deb
177- asset_name : defguard-proxy-${{ env.VERSION }}-${{ matrix.target }}.deb
178- asset_content_type : application/octet-stream
238+ asset_path : defguard-proxy-${{ env.VERSION }}-x86_64-unknown-linux-gnu.rpm
239+ asset_content_type : application/gzip
240+ overwrite : true
179241
180- - name : Build RPM package
181- if : matrix.build == 'linux'
182- uses : bpicode/github-action-fpm@master
242+ - name : Upload Linux aarch64 RPM
243+ uses : shogo82148/actions-upload-release-asset@v1
244+ env :
245+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
183246 with :
184- fpm_args : " defguard-proxy-${{ github.ref_name }}-${{ matrix.target }}=/usr/bin/defguard-proxy defguard-proxy.service=/usr/lib/systemd/system/defguard-proxy.service example-config.toml=/etc/defguard/proxy.toml"
185- fpm_opts : " --architecture ${{ matrix.arch }} --debug --output-type rpm --version ${{ env.VERSION }} --package defguard-proxy-${{ env.VERSION }}-${{ matrix.target }}.rpm"
247+ upload_url : ${{ needs.create-release.outputs.upload_url }}
248+ asset_path : defguard-proxy-${{ env.VERSION }}-aarch64-unknown-linux-gnu.rpm
249+ asset_content_type : application/gzip
250+ overwrite : true
186251
187- - name : Upload RPM
188- if : matrix.build == 'linux'
189- uses : actions/upload-release-asset@v1.0.2
252+ - name : Upload FreeBSD package
253+ uses : shogo82148/actions-upload-release-asset@v1
190254 env :
191255 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
192256 with :
193257 upload_url : ${{ needs.create-release.outputs.upload_url }}
194- asset_path : defguard-proxy- ${{ env.VERSION }}-${{ matrix.target }}.rpm
195- asset_name : defguard-proxy-${{ env.VERSION }}-${{ matrix.target }}.rpm
196- asset_content_type : application/octet-stream
258+ asset_path : defguard-${{ env.VERSION }}_x86_64-unknown-freebsd.pkg
259+ asset_content_type : application/x-pkg
260+ overwrite : true
0 commit comments