-
Notifications
You must be signed in to change notification settings - Fork 3
209 lines (190 loc) · 8.22 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: Publish
on:
push:
tags:
- v*.*.*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-docker-release:
# Ignore tags with -, like v1.0.0-alpha
# This job will build the docker container with the "latest" tag which
# is a tag used in production, thus it should only be run for full releases.
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-')
name: Build Release Docker image
uses: ./.github/workflows/build-docker.yml
with:
tags: |
type=raw,value=latest
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
build-docker-prerelease:
# Only build tags with -, like v1.0.0-alpha
if: startsWith(github.ref, 'refs/tags/') && contains(github.ref, '-')
name: Build Pre-release Docker image
uses: ./.github/workflows/build-docker.yml
with:
tags: |
type=raw,value=pre-release
type=semver,pattern={{version}}
type=sha
# Explicitly disable latest tag. It will be added otherwise.
flavor: |
latest=false
create-release:
name: create-release
runs-on: self-hosted
outputs:
upload_url: ${{ steps.release.outputs.upload_url }}
steps:
- name: Create GitHub release
id: release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
generate_release_notes: true
build-release:
name: Release ${{ matrix.build }}
needs: [create-release]
runs-on:
- self-hosted
- ${{ matrix.os }}
- X64
strategy:
fail-fast: false
matrix:
build: [linux, linux-arm64, freebsd]
include:
- build: linux
arch: amd64
os: Linux
asset_name: defguard-gateway-linux-x86_64
target: x86_64-unknown-linux-gnu
- build: linux-arm64
arch: arm64
os: Linux
asset_name: defguard-gateway-linux-arm64
target: aarch64-unknown-linux-gnu
- build: freebsd
arch: amd64
os: Linux
asset_name: defguard-gateway-freebsd-x86_64
target: x86_64-unknown-freebsd
steps:
# Store the version, stripping any v-prefix
- name: Write release version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo Version: $VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Build release binary
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --locked --release --target ${{ matrix.target }}
- name: Rename binary
run: mv target/${{ matrix.target }}/release/defguard-gateway ${{ matrix.asset_name }}-${{ github.ref_name }}
- name: Tar
uses: a7ul/[email protected]
with:
command: c
files: |
${{ matrix.asset_name }}-${{ github.ref_name }}
outPath: ${{ matrix.asset_name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
- name: Upload release archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ matrix.asset_name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
asset_name: ${{ matrix.asset_name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
asset_content_type: application/octet-stream
- name: Build DEB package
if: matrix.build != 'freebsd'
uses: defGuard/fpm-action@main
with:
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"
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"
- name: Upload DEB
if: matrix.build != 'freebsd'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb
asset_content_type: application/octet-stream
- name: Build RPM package
if: matrix.build == 'linux'
uses: defGuard/fpm-action@main
with:
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"
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"
- name: Upload RPM
if: matrix.build == 'linux'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm
asset_content_type: application/octet-stream
- name: Build FreeBSD package
if: matrix.build == 'freebsd'
uses: defGuard/fpm-action@main
with:
fpm_args:
"${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/local/sbin/defguard-gateway
defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard_gateway
example-config.toml=/etc/defguard/gateway.toml.sample
defguard-rc.conf=/etc/rc.conf.d/defguard_gateway"
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg --freebsd-osversion '*'"
- name: Upload FreeBSD
if: matrix.build == 'freebsd'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg
asset_content_type: application/octet-stream
- name: Build OPNsense package
if: matrix.build == 'freebsd'
uses: defGuard/fpm-action@main
with:
fpm_args:
"${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/local/sbin/defguard-gateway
defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard_gateway
example-config.toml=/etc/defguard/gateway.toml.sample
defguard-rc.conf=/etc/rc.conf.d/defguard_gateway
opnsense/src/etc/=/usr/local/etc/
opnsense/src/opnsense/=/usr/local/opnsense/"
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg --freebsd-osversion '*'"
- name: Upload OPNsense package
if: matrix.build == 'freebsd'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg
asset_name: defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg
asset_content_type: application/octet-stream