48
48
echo "describe=$(git describe --tags --match 'v*.*.*' --always)" >> $GITHUB_OUTPUT
49
49
echo "timestamp=$(git log -1 --format=%ct)" >> $GITHUB_OUTPUT
50
50
51
+ build-assets :
52
+ name : Build assets
53
+ runs-on : ubuntu-22.04
54
+
55
+ permissions :
56
+ contents : read
57
+
58
+ steps :
59
+ - name : Checkout the code
60
+
61
+
62
+ - name : Setup OPA
63
+ uses :
open-policy-agent/[email protected]
64
+ with :
65
+ version : 0.64.1
66
+
67
+ - name : Install frontend Node
68
+
69
+ with :
70
+ node-version : 20
71
+
72
+ - name : Install frontend Node dependencies
73
+ working-directory : ./frontend
74
+ run : npm ci
75
+
76
+ - name : Build frontend
77
+ working-directory : ./frontend
78
+ run : npm run build
79
+
80
+ - name : Build policies
81
+ working-directory : ./policies
82
+ run : make
83
+
84
+ - name : Prepare assets artifact
85
+ run : |
86
+ mkdir -p assets-dist/share
87
+ cp policies/policy.wasm assets-dist/share/policy.wasm
88
+ cp frontend/dist/manifest.json assets-dist/share/manifest.json
89
+ cp -r frontend/dist/ assets-dist/share/assets
90
+ cp -r templates/ assets-dist/share/templates
91
+ cp -r translations/ assets-dist/share/translations
92
+ cp LICENSE assets-dist/LICENSE
93
+ chmod -R u=rwX,go=rX assets-dist/
94
+
95
+ - name : Upload assets
96
+
97
+ with :
98
+ name : assets
99
+ path : assets-dist
51
100
52
101
build-binaries :
53
102
name : Build binaries
@@ -56,6 +105,12 @@ jobs:
56
105
needs :
57
106
- compute-version
58
107
108
+ strategy :
109
+ matrix :
110
+ include :
111
+ - target : x86_64-unknown-linux-gnu
112
+ - target : aarch64-unknown-linux-gnu
113
+
59
114
env :
60
115
VERGEN_GIT_DESCRIBE : ${{ needs.compute-version.outputs.describe }}
61
116
SOURCE_DATE_EPOCH : ${{ needs.compute-version.outputs.timestamp }}
@@ -67,17 +122,11 @@ jobs:
67
122
- name : Checkout the code
68
123
69
124
70
- - name : Setup OPA
71
- uses :
open-policy-agent/[email protected]
72
- with :
73
- version : 0.64.1
74
-
75
125
- name : Install Rust toolchain
76
126
uses : dtolnay/rust-toolchain@stable
77
127
with :
78
128
targets : |
79
- x86_64-unknown-linux-gnu
80
- aarch64-unknown-linux-gnu
129
+ ${{ matrix.target }}
81
130
82
131
- name : Setup sccache
83
132
uses :
mozilla-actions/[email protected]
@@ -92,62 +141,74 @@ jobs:
92
141
with :
93
142
tool : cargo-zigbuild
94
143
95
- - name : Install frontend Node
96
-
97
- with :
98
- node-version : 20
99
-
100
- - name : Install frontend Node dependencies
101
- working-directory : ./frontend
102
- run : npm ci
103
-
104
- - name : Build frontend
105
- working-directory : ./frontend
106
- run : npm run build
107
-
108
- - name : Build policies
109
- working-directory : ./policies
110
- run : make
111
-
112
144
- name : Build the binary
113
145
run : |
114
146
cargo zigbuild \
115
147
--release \
116
- --target x86_64-unknown-linux-gnu.2.17 \
117
- --target aarch64-unknown-linux-gnu.2.17 \
148
+ --target ${{ matrix.target }}.2.17 \
118
149
--no-default-features \
119
150
--features dist \
120
151
-p mas-cli
121
152
122
- - name : Create one archive per architecture
153
+ - name : Upload binary artifact
154
+
155
+ with :
156
+ name : binary-${{ matrix.target }}
157
+ path : target/${{ matrix.target }}/release/mas-cli
158
+
159
+ assemble-archives :
160
+ name : Assemble release archives
161
+ runs-on : ubuntu-22.04
162
+
163
+ needs :
164
+ - build-assets
165
+ - build-binaries
166
+
167
+ permissions :
168
+ contents : read
169
+
170
+ steps :
171
+ - name : Download assets
172
+ uses : actions/download-artifact@v4
173
+ with :
174
+ name : assets
175
+ path : assets-dist
176
+
177
+ - name : Download binary x86_64
178
+ uses : actions/download-artifact@v4
179
+ with :
180
+ name : binary-x86_64-unknown-linux-gnu
181
+ path : binary-x86_64
182
+
183
+ - name : Download binary aarch64
184
+ uses : actions/download-artifact@v4
185
+ with :
186
+ name : binary-aarch64-unknown-linux-gnu
187
+ path : binary-aarch64
188
+
189
+ - name : Create final archives
123
190
run : |
124
191
for arch in x86_64 aarch64; do
125
- # Create one directory per architecture
126
- mkdir -p dist/${arch}/share/
127
- # Copy the artifacts to the right place
128
- cp policies/policy.wasm dist/${arch}/share/policy.wasm
129
- cp frontend/dist/manifest.json dist/${arch}/share/manifest.json
130
- cp -r frontend/dist/ dist/${arch}/share/assets
131
- cp -r templates/ dist/${arch}/share/templates
132
- cp -r translations/ dist/${arch}/share/translations
133
- cp LICENSE dist/${arch}/LICENSE
192
+ mkdir -p dist/${arch}/share
193
+ cp -r assets-dist/share/* dist/${arch}/share/
194
+ cp assets-dist/LICENSE dist/${arch}/LICENSE
195
+ cp binary-$arch/mas-cli dist/${arch}/mas-cli
134
196
chmod -R u=rwX,go=rX dist/${arch}/
135
-
136
- # Copy the binary to the right place
137
- cp target/${arch}-unknown-linux-gnu/release/mas-cli dist/${arch}/
138
197
chmod u=rwx,go=rx dist/${arch}/mas-cli
139
-
140
- # Create the archive
141
198
tar -czvf mas-cli-${arch}-linux.tar.gz --owner=0 --group=0 -C dist/${arch}/ .
142
199
done
143
200
144
- - name : Upload the artifacts
201
+ - name : Upload aarch64 archive
202
+
203
+ with :
204
+ name : mas-cli-aarch64-linux
205
+ path : mas-cli-aarch64-linux.tar.gz
206
+
207
+ - name : Upload x86_64 archive
145
208
146
209
with :
147
- name : binaries
148
- path : |
149
- mas-cli-aarch64-linux.tar.gz
150
- mas-cli-x86_64-linux.tar.gz
210
+ name : mas-cli-x86_64-linux
211
+ path : mas-cli-x86_64-linux.tar.gz
151
212
152
213
build-image :
153
214
name : Build and push Docker image
@@ -325,15 +386,16 @@ jobs:
325
386
if : startsWith(github.ref, 'refs/tags/')
326
387
runs-on : ubuntu-latest
327
388
needs :
328
- - build-binaries
389
+ - assemble-archives
329
390
- build-image
330
391
- syn2mas
331
392
steps :
332
393
- name : Download the artifacts from the previous job
333
394
uses : actions/download-artifact@v4
334
395
with :
335
- name : binaries
396
+ pattern : mas-cli-*
336
397
path : artifacts
398
+ merge-multiple : true
337
399
338
400
- name : Prepare a release
339
401
uses : softprops/action-gh-release@v2
@@ -387,19 +449,19 @@ jobs:
387
449
name : Update the unstable release
388
450
runs-on : ubuntu-24.04
389
451
needs :
390
- - build-binaries
452
+ - assemble-archives
391
453
- build-image
392
454
if : github.ref == 'refs/heads/main'
393
455
394
456
permissions :
395
457
contents : write
396
-
397
458
steps :
398
459
- name : Download the artifacts from the previous job
399
460
uses : actions/download-artifact@v4
400
461
with :
401
- name : binaries
462
+ pattern : mas-cli-*
402
463
path : artifacts
464
+ merge-multiple : true
403
465
404
466
- name : Update unstable git tag
405
467
0 commit comments