@@ -2,13 +2,13 @@ name: Build
2
2
3
3
on :
4
4
push :
5
- branches : [ main ]
5
+ branches : [main]
6
6
tags :
7
- - ' v* '
7
+ - " v* "
8
8
9
9
# Only run for pull requests if relevant files were changed
10
10
pull_request :
11
- branches : [ main ]
11
+ branches : [main]
12
12
paths :
13
13
- Dockerfile
14
14
- docker-bake.hcl
33
33
name : Build binaries
34
34
runs-on : ubuntu-22.04
35
35
36
- env :
37
- SDKROOT : /opt/MacOSX11.3.sdk
38
-
39
36
permissions :
40
37
contents : read
41
38
@@ -54,22 +51,17 @@ jobs:
54
51
targets : |
55
52
x86_64-unknown-linux-gnu
56
53
aarch64-unknown-linux-gnu
57
- x86_64-apple-darwin
58
- aarch64-apple-darwin
59
54
60
55
- name : Setup sccache
61
56
uses :
mozilla-actions/[email protected]
62
57
63
58
- name : Install zig
64
59
uses : goto-bus-stop/setup-zig@v2
65
60
with :
66
- version : 0.11 .0
61
+ version : 0.13 .0
67
62
68
63
- name : Install cargo-zigbuild
69
- run : curl -L https://github.com/rust-cross/cargo-zigbuild/releases/download/v0.18.4/cargo-zigbuild-v0.18.4.x86_64-unknown-linux-musl.tar.gz | tar -z -x -C /usr/local/bin
70
-
71
- - name : Download the macOS SDK
72
- run : curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz" | tar -J -x -C /opt
64
+ run : curl -L https://github.com/rust-cross/cargo-zigbuild/releases/download/v0.19.1/cargo-zigbuild-v0.19.1.x86_64-unknown-linux-musl.tar.gz | tar -z -x -C /usr/local/bin
73
65
74
66
- name : Install frontend Node
75
67
@@ -88,44 +80,45 @@ jobs:
88
80
working-directory : ./policies
89
81
run : make
90
82
91
- - name : Force Cargo to create the target directory
92
- # Run `cargo clean` with an empty package name to force it to create the target directory
93
- # This fails because there is no package with an empty name, but the target directory is created
94
- # See https://github.com/rust-lang/cargo/issues/12441
95
- # This is needed because `cargo-zigbuild` sometimes (wrongly) creates the target directory
96
- # See https://github.com/rust-cross/cargo-zigbuild/issues/165
97
- run : |
98
- cargo clean -p '' \
99
- --target x86_64-unknown-linux-gnu \
100
- --target aarch64-unknown-linux-gnu \
101
- --target x86_64-apple-darwin \
102
- --target aarch64-apple-darwin \
103
- || true
104
-
105
83
- name : Build the binary
106
84
run : |
107
85
cargo zigbuild \
108
86
--release \
109
87
--target x86_64-unknown-linux-gnu.2.17 \
110
88
--target aarch64-unknown-linux-gnu.2.17 \
111
- --target x86_64-apple-darwin \
112
- --target aarch64-apple-darwin \
113
89
--no-default-features \
114
90
--features dist \
115
91
-p mas-cli
116
92
93
+ - name : Create one archive per architecture
94
+ run : |
95
+ for arch in x86_64 aarch64; do
96
+ # Create one directory per architecture
97
+ mkdir -p dist/${arch}/share/
98
+ # Copy the artifacts to the right place
99
+ cp policies/policy.wasm dist/${arch}/share/policy.wasm
100
+ cp frontend/dist/manifest.json dist/${arch}/share/manifest.json
101
+ cp -r frontend/dist/ dist/${arch}/share/assets
102
+ cp -r templates/ dist/${arch}/share/templates
103
+ cp -r translations/ dist/${arch}/share/translations
104
+ cp LICENSE dist/${arch}/LICENSE
105
+ chmod -R u=rwX,go=rX dist/${arch}/
106
+
107
+ # Copy the binary to the right place
108
+ cp target/${arch}-unknown-linux-gnu/release/mas-cli dist/${arch}/
109
+ chmod u=rwx,go=rx dist/${arch}/mas-cli
110
+
111
+ # Create the archive
112
+ tar -czvf mas-cli-${arch}-linux.tar.gz --owner=0 --group=0 -C dist/${arch}/ .
113
+ done
114
+
117
115
- name : Upload the artifacts
118
116
119
117
with :
120
118
name : binaries
121
119
path : |
122
- target/*/release/mas-cli
123
- frontend/dist/
124
- policies/policy.wasm
125
- templates/
126
- translations/
127
- LICENSE
128
-
120
+ mas-cli-aarch64-linux.tar.gz
121
+ mas-cli-x86_64-linux.tar.gz
129
122
130
123
build-image :
131
124
name : Build and push Docker image
@@ -261,7 +254,6 @@ jobs:
261
254
"${{ env.IMAGE }}@${{ fromJSON(steps.output.outputs.metadata).regular.digest }}" \
262
255
"${{ env.IMAGE }}@${{ fromJSON(steps.output.outputs.metadata).debug.digest }}" \
263
256
"${{ env.IMAGE_SYN2MAS }}@${{ fromJSON(steps.output.outputs.metadata).syn2mas.digest }}"
264
-
265
257
266
258
syn2mas :
267
259
name : Release syn2mas on NPM
@@ -291,7 +283,6 @@ jobs:
291
283
provenance : true
292
284
dry-run : ${{ !startsWith(github.ref, 'refs/tags/') }}
293
285
294
-
295
286
release :
296
287
name : Release
297
288
if : startsWith(github.ref, 'refs/tags/')
@@ -307,38 +298,15 @@ jobs:
307
298
name : binaries
308
299
path : artifacts
309
300
310
- - name : Prepare the archive directory
311
- run : |
312
- mkdir -p dist/share/
313
- mv artifacts/policies/policy.wasm dist/share/policy.wasm
314
- mv artifacts/frontend/dist/manifest.json dist/share/manifest.json
315
- mv artifacts/frontend/dist/ dist/share/assets
316
- mv artifacts/templates/ dist/share/templates
317
- mv artifacts/translations/ dist/share/translations
318
- mv artifacts/LICENSE dist/LICENSE
319
- chmod -R u=rwX,go=rX dist/
320
-
321
- - name : Create the archives
322
- run : |
323
- for arch in x86_64 aarch64; do
324
- mv artifacts/target/${arch}-unknown-linux-gnu/release/mas-cli dist/mas-cli
325
- chmod u=rwx,go=rx dist/mas-cli
326
- tar -czvf mas-cli-${arch}-linux.tar.gz --owner=0 --group=0 -C dist/ .
327
-
328
- mv artifacts/target/${arch}-apple-darwin/release/mas-cli dist/mas-cli
329
- chmod u=rwx,go=rx dist/mas-cli
330
- tar -czvf mas-cli-${arch}-macos.tar.gz --owner=0 --group=0 -C dist/ .
331
- done
332
-
333
301
- name : Prepare a release
334
302
uses : softprops/action-gh-release@v2
335
303
with :
336
304
body : |
337
305
### Docker image
338
-
339
- Regular image:
340
-
341
- - Digest:
306
+
307
+ Regular image:
308
+
309
+ - Digest:
342
310
```
343
311
${{ env.IMAGE }}@${{ fromJSON(needs.build-image.outputs.metadata).regular.digest }}
344
312
```
@@ -347,10 +315,10 @@ jobs:
347
315
${{ join(fromJSON(needs.build-image.outputs.metadata).regular.tags, '
348
316
') }}
349
317
```
350
-
351
- Debug variant:
352
-
353
- - Digest:
318
+
319
+ Debug variant:
320
+
321
+ - Digest:
354
322
```
355
323
${{ env.IMAGE }}@${{ fromJSON(needs.build-image.outputs.metadata).debug.digest }}
356
324
```
@@ -359,10 +327,10 @@ jobs:
359
327
${{ join(fromJSON(needs.build-image.outputs.metadata).debug.tags, '
360
328
') }}
361
329
```
362
-
363
- `syn2mas` migration tool:
364
-
365
- - Digest:
330
+
331
+ `syn2mas` migration tool:
332
+
333
+ - Digest:
366
334
```
367
335
${{ env.IMAGE_SYN2MAS }}@${{ fromJSON(needs.build-image.outputs.metadata).syn2mas.digest }}
368
336
```
@@ -373,8 +341,6 @@ jobs:
373
341
```
374
342
375
343
files : |
376
- mas-cli-aarch64-linux.tar.gz
377
- mas-cli-aarch64-macos.tar.gz
378
- mas-cli-x86_64-linux.tar.gz
379
- mas-cli-x86_64-macos.tar.gz
344
+ artifacts/mas-cli-aarch64-linux.tar.gz
345
+ artifacts/mas-cli-x86_64-linux.tar.gz
380
346
draft : true
0 commit comments