Skip to content

Commit 056e4a2

Browse files
authored
Get rid of Cross-rs (#308)
1 parent f89ec9e commit 056e4a2

4 files changed

Lines changed: 197 additions & 188 deletions

File tree

.github/workflows/release.yml

Lines changed: 151 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1117
jobs:
1218
build-docker-release:
1319
# Ignore tags with -, like v1.0.0-alpha
@@ -45,174 +51,215 @@ 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-release:
61-
name: Release ${{ matrix.build }}
62-
needs: [create-release]
68+
needs:
69+
- create-release
6370
runs-on:
6471
- self-hosted
65-
- ${{ matrix.os }}
72+
- Linux
6673
- X64
67-
strategy:
68-
fail-fast: false
69-
matrix:
70-
build: [linux, linux-arm64, freebsd]
71-
include:
72-
- build: linux
73-
arch: amd64
74-
os: Linux
75-
asset_name: defguard-gateway-linux-x86_64
76-
target: x86_64-unknown-linux-gnu
77-
- build: linux-arm64
78-
arch: arm64
79-
os: Linux
80-
asset_name: defguard-gateway-linux-arm64
81-
target: aarch64-unknown-linux-gnu
82-
- build: freebsd
83-
arch: amd64
84-
os: Linux
85-
asset_name: defguard-gateway-freebsd-x86_64
86-
target: x86_64-unknown-freebsd
8774
steps:
8875
# Store the version, stripping any v-prefix
8976
- name: Write release version
9077
run: |
9178
VERSION=${GITHUB_REF_NAME#v}
9279
echo Version: $VERSION
9380
echo "VERSION=$VERSION" >> $GITHUB_ENV
81+
9482
- name: Checkout
9583
uses: actions/checkout@v6
9684
with:
9785
submodules: recursive
9886

9987
- name: Install Rust stable
100-
uses: actions-rs/toolchain@v1
88+
uses: dtolnay/rust-toolchain@stable
10189
with:
102-
toolchain: 1.89.0 # "stable" causes rust-lld: error on aarch64-linux
103-
target: ${{ matrix.target }}
104-
override: true
90+
targets: "aarch64-unknown-linux-gnu"
91+
92+
- name: Run sccache-cache
93+
uses: mozilla-actions/sccache-action@v0.0.9
94+
95+
- name: Build Linux x86_64 binary
96+
run: |
97+
cargo build --locked --release --target x86_64-unknown-linux-gnu
98+
mv target/x86_64-unknown-linux-gnu/release/defguard-gateway defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu
99+
tar -zcf defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz \
100+
defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu
101+
102+
- name: Build Linux aarch64 binary
103+
env:
104+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
105+
PKG_CONFIG_SYSROOT_DIR: /usr/lib/aarch64-linux-gnu
106+
run: |
107+
cargo build --locked --release --target aarch64-unknown-linux-gnu
108+
mv target/aarch64-unknown-linux-gnu/release/defguard-gateway defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu
109+
tar -zcf defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz \
110+
defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu
105111
106-
- name: Setup `packer`
107-
uses: hashicorp/setup-packer@main
108-
id: setup
112+
- name: Build FreeBSD binary
113+
run: |
114+
rsync -rlptxzH -e 'ssh -l root' --del ./ freebsd:work/gateway/
115+
ssh root@freebsd 'cd work/gateway && cargo build --locked --release'
116+
scp root@freebsd:work/gateway/target/release/defguard-gateway defguard-gateway-${{ env.VERSION }}-x86_64-unknown-freebsd
117+
tar -zcf defguard-gateway-${{ env.VERSION }}-x86_64-unknown-freebsd.tar.gz \
118+
defguard-gateway-${{ env.VERSION }}-x86_64-unknown-freebsd
119+
120+
- name: Build x86_64 DEB package
121+
uses: defGuard/fpm-action@main
122+
with:
123+
fpm_args:
124+
"defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu=/usr/bin/defguard-gateway
125+
defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
126+
example-config.toml=/etc/defguard/gateway.toml.sample"
127+
fpm_opts: "--architecture amd64 --output-type deb --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.deb --after-install after-install.sh"
128+
129+
- name: Build aarch64 DEB package
130+
uses: defGuard/fpm-action@main
131+
with:
132+
fpm_args:
133+
"defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu=/usr/bin/defguard-gateway
134+
defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
135+
example-config.toml=/etc/defguard/gateway.toml.sample"
136+
fpm_opts: "--architecture arm64 --output-type deb --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.deb --after-install after-install.sh"
109137

110-
- name: Build release binary
111-
uses: actions-rs/cargo@v1
138+
- name: Build x86_64 RPM package
139+
uses: defGuard/fpm-action@main
112140
with:
113-
use-cross: true
114-
command: build
115-
args: --locked --release --target ${{ matrix.target }}
141+
fpm_args:
142+
"defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu=/usr/bin/defguard-gateway
143+
defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
144+
example-config.toml=/etc/defguard/gateway.toml.sample"
145+
fpm_opts: "--architecture amd64 --output-type rpm --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.rpm --after-install after-install.sh"
116146

117-
- name: Rename binary
118-
run: mv target/${{ matrix.target }}/release/defguard-gateway ${{ matrix.asset_name }}-${{ github.ref_name }}
147+
- name: Build aarch64 RPM package
148+
uses: defGuard/fpm-action@main
149+
with:
150+
fpm_args:
151+
"defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu=/usr/bin/defguard-gateway
152+
defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
153+
example-config.toml=/etc/defguard/gateway.toml.sample"
154+
fpm_opts: "--architecture arm64 --output-type rpm --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.rpm --after-install after-install.sh"
119155

120-
- name: Tar
121-
uses: a7ul/tar-action@v1.2.0
156+
- name: Build FreeBSD package
157+
uses: defGuard/fpm-action@main
122158
with:
123-
command: c
124-
files: |
125-
${{ matrix.asset_name }}-${{ github.ref_name }}
126-
outPath: ${{ matrix.asset_name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
159+
fpm_args:
160+
"defguard-gateway-${{ env.VERSION }}-x86_64-unknown-freebsd=/usr/local/bin/defguard-gateway
161+
defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard-gateway
162+
example-config.toml=/etc/defguard/gateway.toml.sample"
163+
fpm_opts: "--architecture amd64 --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}_x86_64-unknown-freebsd.pkg --freebsd-osversion '*' --depends openssl"
127164

128-
- name: Upload release archive
129-
uses: actions/upload-release-asset@v1
165+
- name: Build OPNsense package
166+
uses: defGuard/fpm-action@main
167+
with:
168+
fpm_args:
169+
"defguard-gateway-${{ env.VERSION }}-x86_64-unknown-freebsd=/usr/local/bin/defguard-gateway
170+
defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard-gateway
171+
example-config.toml=/etc/defguard/gateway.toml.sample
172+
defguard-rc.conf=/etc/rc.conf.d/defguard_gateway
173+
opnsense/src/etc/=/usr/local/etc/
174+
opnsense/src/opnsense/=/usr/local/opnsense/"
175+
fpm_opts: "--architecture amd64 --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}_x86_64-unknown-opnsense.pkg --freebsd-osversion '*' --depends openssl"
176+
177+
- name: Upload Linux x86_64 archive
178+
uses: shogo82148/actions-upload-release-asset@v1
130179
env:
131180
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132181
with:
133182
upload_url: ${{ needs.create-release.outputs.upload_url }}
134-
asset_path: ${{ matrix.asset_name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
135-
asset_name: ${{ matrix.asset_name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
136-
asset_content_type: application/octet-stream
183+
asset_path: defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz
184+
asset_content_type: application/gzip
185+
overwrite: true
137186

138-
- name: Build DEB package
139-
if: matrix.build != 'freebsd'
140-
uses: defGuard/fpm-action@main
187+
- name: Upload Linux aarch64 archive
188+
uses: shogo82148/actions-upload-release-asset@v1
189+
env:
190+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141191
with:
142-
fpm_args: "${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/sbin/defguard-gateway defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service example-config.toml=/etc/defguard/gateway.toml.sample"
143-
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type deb --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb --after-install after-install.sh"
192+
upload_url: ${{ needs.create-release.outputs.upload_url }}
193+
asset_path: defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz
194+
asset_content_type: application/gzip
195+
overwrite: true
144196

145-
- name: Upload DEB
146-
if: matrix.build != 'freebsd'
147-
uses: actions/upload-release-asset@v1
197+
- name: Upload FreeBSD x86_64 archive
198+
uses: shogo82148/actions-upload-release-asset@v1
148199
env:
149200
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150201
with:
151202
upload_url: ${{ needs.create-release.outputs.upload_url }}
152-
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb
153-
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb
154-
asset_content_type: application/octet-stream
203+
asset_path: defguard-gateway-${{ env.VERSION }}-x86_64-unknown-freebsd.tar.gz
204+
asset_content_type: application/gzip
205+
overwrite: true
155206

156-
- name: Build RPM package
157-
if: matrix.build == 'linux'
158-
uses: defGuard/fpm-action@main
207+
- name: Upload Linux x86_64 DEB
208+
uses: shogo82148/actions-upload-release-asset@v1
209+
env:
210+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159211
with:
160-
fpm_args: "${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/sbin/defguard-gateway defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service example-config.toml=/etc/defguard/gateway.toml.sample"
161-
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type rpm --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm --after-install after-install.sh"
212+
upload_url: ${{ needs.create-release.outputs.upload_url }}
213+
asset_path: defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.deb
214+
asset_content_type: application/gzip
215+
overwrite: true
162216

163-
- name: Upload RPM
164-
if: matrix.build == 'linux'
165-
uses: actions/upload-release-asset@v1
217+
- name: Upload Linux aarch64 DEB
218+
uses: shogo82148/actions-upload-release-asset@v1
166219
env:
167220
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168221
with:
169222
upload_url: ${{ needs.create-release.outputs.upload_url }}
170-
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm
171-
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm
172-
asset_content_type: application/octet-stream
223+
asset_path: defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.deb
224+
asset_content_type: application/gzip
225+
overwrite: true
173226

174-
- name: Build FreeBSD package
175-
if: matrix.build == 'freebsd'
176-
uses: defGuard/fpm-action@main
227+
- name: Upload Linux x86_64 RPM
228+
uses: shogo82148/actions-upload-release-asset@v1
229+
env:
230+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177231
with:
178-
fpm_args:
179-
"${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/local/sbin/defguard-gateway
180-
defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard_gateway
181-
example-config.toml=/etc/defguard/gateway.toml.sample
182-
defguard-rc.conf=/etc/rc.conf.d/defguard_gateway"
183-
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg --freebsd-osversion '*'"
232+
upload_url: ${{ needs.create-release.outputs.upload_url }}
233+
asset_path: defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.rpm
234+
asset_content_type: application/gzip
235+
overwrite: true
184236

185-
- name: Upload FreeBSD
186-
if: matrix.build == 'freebsd'
187-
uses: actions/upload-release-asset@v1
237+
- name: Upload Linux aarch64 RPM
238+
uses: shogo82148/actions-upload-release-asset@v1
188239
env:
189240
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
190241
with:
191242
upload_url: ${{ needs.create-release.outputs.upload_url }}
192-
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg
193-
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg
194-
asset_content_type: application/octet-stream
243+
asset_path: defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.rpm
244+
asset_content_type: application/gzip
245+
overwrite: true
195246

196-
- name: Build OPNsense package
197-
if: matrix.build == 'freebsd'
198-
uses: defGuard/fpm-action@main
247+
- name: Upload FreeBSD package
248+
uses: shogo82148/actions-upload-release-asset@v1
249+
env:
250+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
199251
with:
200-
fpm_args:
201-
"${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/local/sbin/defguard-gateway
202-
defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard_gateway
203-
example-config.toml=/etc/defguard/gateway.toml.sample
204-
defguard-rc.conf=/etc/rc.conf.d/defguard_gateway
205-
opnsense/src/etc/=/usr/local/etc/
206-
opnsense/src/opnsense/=/usr/local/opnsense/"
207-
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg --freebsd-osversion '*'"
252+
upload_url: ${{ needs.create-release.outputs.upload_url }}
253+
asset_path: defguard-gateway-${{ env.VERSION }}_x86_64-unknown-freebsd.pkg
254+
asset_content_type: application/x-pkg
255+
overwrite: true
208256

209257
- name: Upload OPNsense package
210-
if: matrix.build == 'freebsd'
211-
uses: actions/upload-release-asset@v1
258+
uses: shogo82148/actions-upload-release-asset@v1
212259
env:
213260
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
214261
with:
215262
upload_url: ${{ needs.create-release.outputs.upload_url }}
216-
asset_path: defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg
217-
asset_name: defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg
218-
asset_content_type: application/octet-stream
263+
asset_path: defguard-gateway-${{ env.VERSION }}_x86_64-unknown-opnsense.pkg
264+
asset_content_type: application/x-pkg
265+
overwrite: true

.github/workflows/sbom.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
severity: "CRITICAL,HIGH,MEDIUM,LOW"
6363
scanners: "vuln"
6464

65-
- name: Create docker image security advisory file with Trivy
65+
- name: Create Docker image security advisory file with Trivy
6666
uses: aquasecurity/trivy-action@0.35.0
6767
with:
6868
image-ref: "ghcr.io/defguard/gateway:${{ steps.vars.outputs.VERSION }}"
@@ -79,5 +79,5 @@ jobs:
7979
with:
8080
upload_url: ${{ inputs.upload_url }}
8181
asset_path: "defguard-*.json"
82-
asset_content_type: application/octet-stream
82+
asset_content_type: application/json
8383
overwrite: true

0 commit comments

Comments
 (0)