-
Notifications
You must be signed in to change notification settings - Fork 0
503 lines (488 loc) · 16.5 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
name: Rust Build, Test, and Release
### https://github.com/harmless-tech/rust-github-actions
on:
push:
tags:
- "v**"
workflow_dispatch:
env:
bin-name: qstract
feature-set: ''
hack-group: ''
cache: false
CARGO_TERM_COLOR: always
jobs:
release:
outputs:
tag: ${{ github.ref_name }}
name: ${{ github.ref_name }}
prerelease: ${{ steps.regex-tag.outputs.match == '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: KyoriPowered/action-regex-match@v4
id: regex-tag
with:
text: ${{ github.ref }}
regex: '^refs\/tags\/v\d+\.\d+\.\d+$'
# publish-crates-io:
# if: ${{ ! contains(github.ref, '-dev') }}
# runs-on: ubuntu-latest
# needs: [ release, check-fmt, clippy, ink-cross, cross, apple-darwin, pc-windows-msvc ]
# steps:
# - uses: actions/checkout@v4
# - name: Update Rust
# run: |
# rustup update
# rustc --version
# - name: Publish
# run: cargo publish --verbose --locked --token ${CRATES_TOKEN}
# env:
# CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
publish-github-releases:
runs-on: ubuntu-latest
needs: [ release, check-fmt, clippy, ink-cross, cross, apple-darwin, pc-windows-msvc ]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Merge hashes
shell: bash
run: |
set -euxo pipefail
echo -n "" > hashes.sha256
for D in target-*; do
if [ -d "${D}" ]; then
echo "${D}"
pushd "${D}"
cat *.sha256 >> ../hashes.sha256
popd
fi
done
# - name: Sign archives
# shell: bash
# run: |
# set -euxo pipefail
# eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
# brew install minisign
# echo -n "$SIGNING_KEY" | base64 --decode > ~/.minisign_secret.key
# for D in target-*; do
# if [ -d "${D}" ]; then
# echo "${D}"
# pushd "${D}"
#
# for file in ./*.tar.gz ./*.zip; do
# if [ -f "$file" ]; then
# minisign -S -s ~/.minisign_secret.key -m $file
# minisign -V -p ../keys/cargo-prebuilt.pub -m $file
# fi
# done
#
# popd
# fi
# done
# rm -f ~/.minisign_secret.key
# env:
# SIGNING_KEY: ${{ secrets.MINISIGN_SIGNING_KEY }}
- name: Create and push artifacts to release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.release.outputs.tag }}
name: ${{ needs.release.outputs.name }}
allowUpdates: true
prerelease: ${{ needs.release.outputs.prerelease }}
artifacts: "target-*/qstract-*,hashes.sha256"
body: ""
check-fmt:
env:
CARGO_TERM_COLOR: never
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install nightly
run: rustup toolchain install nightly --allow-downgrade -c rustfmt
- name: Rustfmt Check
run: |
set -o pipefail
cargo +nightly fmt --check 2>&1 | tee .step-data.txt
- name: Put into summary (success)
if: success()
run: echo "Success" >> $GITHUB_STEP_SUMMARY
- name: Put into summary (failure)
if: failure()
run: |
echo "Failed!" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`shell" >> $GITHUB_STEP_SUMMARY
cat .step-data.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
clippy:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-pc-windows-msvc
os: windows-latest
env:
CARGO_TERM_COLOR: never
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: |
rustup update
rustc --version
- uses: Swatinem/rust-cache@v2
if: ${{ env.cache == 'true' }}
- name: Clippy Check
shell: bash
run: |
set -o pipefail
cargo clippy --all-targets --verbose --workspace --release --locked -- -D warnings 2>&1 | tee .step-data.txt
cargo clippy --all-targets --verbose --workspace --release --locked ${{ env.feature-set }} -- -D warnings 2>&1 | tee .step-data.txt
- name: Put into summary (success)
if: success()
shell: bash
run: echo "Success" >> $GITHUB_STEP_SUMMARY
- name: Put into summary (failure)
if: failure()
shell: bash
run: |
echo "Failed!" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`shell" >> $GITHUB_STEP_SUMMARY
cat .step-data.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cargo-hack:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-pc-windows-msvc
os: windows-latest
env:
CARGO_TERM_COLOR: never
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: |
rustup update
rustc --version
- uses: cargo-prebuilt/cargo-prebuilt-action@v3
with:
pkgs: cargo-hack
- uses: Swatinem/rust-cache@v2
if: ${{ env.cache == 'true' }}
- name: Hack Check (each-feature)
shell: bash
run: |
set -o pipefail
cargo hack check --each-feature --no-dev-deps --verbose --workspace --release --locked 2>&1 | tee .step-data.txt
- name: Hack Check (feature-powerset)
shell: bash
run: |
set -o pipefail
cargo hack check --feature-powerset ${{ env.hack-group }} --no-dev-deps --verbose --workspace --release --locked 2>&1 | tee .step-data.txt
- name: Put into summary (success)
if: success()
shell: bash
run: echo "Success" >> $GITHUB_STEP_SUMMARY
- name: Put into summary (failure)
if: failure()
shell: bash
run: |
echo "Failed!" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`shell" >> $GITHUB_STEP_SUMMARY
cat .step-data.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cargo-msrv:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-pc-windows-msvc
os: windows-latest
env:
CARGO_TERM_COLOR: never
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: |
rustup update
rustc --version
- uses: cargo-prebuilt/cargo-prebuilt-action@v3
with:
pkgs: cargo-binstall
- name: Install cargo-msrv
run: cargo binstall --version 0.15.1 --no-confirm cargo-msrv
- uses: Swatinem/rust-cache@v2
if: ${{ env.cache == 'true' }}
- name: MSRV Check
shell: bash
run: |
set -o pipefail
cargo msrv verify -- cargo check --verbose --release --locked 2>&1 | tee .step-data.txt
- name: Put into summary (success)
if: success()
shell: bash
run: echo "Success" >> $GITHUB_STEP_SUMMARY
- name: Put into summary (failure)
if: failure()
shell: bash
run: |
echo "Failed!" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`shell" >> $GITHUB_STEP_SUMMARY
cat .step-data.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cargo-deny:
env:
CARGO_TERM_COLOR: never
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: |
rustup update
rustc --version
- uses: cargo-prebuilt/cargo-prebuilt-action@v3
with:
pkgs: cargo-deny
- name: Cargo Deny
shell: bash
run: |
set -o pipefail
cargo deny check 2>&1 | tee .step-data.txt
- name: Put into summary (success)
if: success()
shell: bash
run: echo "Success" >> $GITHUB_STEP_SUMMARY
- name: Put into summary (failure)
if: failure()
shell: bash
run: |
echo "Failed!" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`shell" >> $GITHUB_STEP_SUMMARY
cat .step-data.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
reports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: |
rustup update
rustc --version
- uses: cargo-prebuilt/cargo-prebuilt-action@v3
with:
pkgs: cargo-audit
- uses: Swatinem/rust-cache@v2
if: ${{ env.cache == 'true' }}
- name: Cache Advisory DB
uses: actions/cache@v4
with:
path: |
~/.cargo/advisory-db
key: cache-advisory-db
- name: Deps Report
run: |
test -f Cargo.lock || cargo generate-lockfile --verbose
echo "### Deps:" >> $GITHUB_STEP_SUMMARY
echo "Generated on: $(date --utc)" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cargo tree --verbose -e normal,build --locked >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Audit Report
run: |
echo "### Audit:" >> $GITHUB_STEP_SUMMARY
echo "Generated on: $(date --utc)" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cargo audit >> $GITHUB_STEP_SUMMARY || true
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
ink-cross:
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-gnu
can-test: false
- target: aarch64-unknown-linux-musl
can-test: false
- target: armv7-unknown-linux-gnueabihf
can-test: false
- target: armv7-unknown-linux-musleabihf
can-test: false
- target: powerpc64le-unknown-linux-gnu
can-test: false
- target: riscv64gc-unknown-linux-gnu
can-test: false
- target: s390x-unknown-linux-gnu
can-test: false
- target: x86_64-unknown-linux-gnu
can-test: true
- target: x86_64-unknown-linux-musl
can-test: true
runs-on: ubuntu-latest
needs: [ check-fmt, clippy, cargo-hack, cargo-msrv, cargo-deny ]
steps:
- uses: actions/checkout@v4
- uses: cargo-prebuilt/cargo-prebuilt-action@v3
with:
pkgs: coreutils
- uses: Swatinem/rust-cache@v2
if: ${{ env.cache == 'true' }}
- name: Build
run: |
docker run --rm \
--userns host --user $(id -u):$(id -g) \
-v $HOME/.cargo/registry:/usr/local/cargo/registry \
-v ./:/project \
ghcr.io/cargo-prebuilt/ink-cross:stable-${{ matrix.target }} \
auditable build --verbose --workspace --release --locked --target ${{ matrix.target }} ${{ env.feature-set }}
- name: Run tests
if: ${{ matrix.can-test }}
run: |
BIN_LOC="./target/${{ matrix.target }}/release/${{ env.bin-name }}" ./test/_test.sh
- name: Rename
run: cp ./target/${{ matrix.target }}/release/${{ env.bin-name }} ./${{ env.bin-name }}-${{ matrix.target }}
- name: Chmod
run: chmod +x ./${{ env.bin-name }}-${{ matrix.target }}
- name: Hash
run: echo "$(coreutils sha256sum ./${{ env.bin-name }}-${{ matrix.target }})" > ${{ matrix.target }}.sha256
- name: Artifact
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.target }}
path: |
${{ env.bin-name }}-${{ matrix.target }}
${{ matrix.target }}.sha256
cross:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-freebsd
can-test: false
- target: x86_64-unknown-netbsd
can-test: false
- target: x86_64-unknown-illumos
can-test: false
- target: powerpc64-unknown-linux-gnu
can-test: true
runs-on: ubuntu-latest
needs: [ check-fmt, clippy, cargo-hack, cargo-msrv, cargo-deny ]
steps:
- uses: actions/checkout@v4
- name: Update Rust and add target
run: |
rustup update
rustc --version
rustup target add ${{ matrix.target }}
- uses: cargo-prebuilt/cargo-prebuilt-action@v3
with:
pkgs: cross,coreutils
- uses: Swatinem/rust-cache@v2
if: ${{ env.cache == 'true' }}
- name: Build
run: cross build --verbose --workspace --release --locked --target ${{ matrix.target }} ${{ env.feature-set }}
- name: Rename
run: cp ./target/${{ matrix.target }}/release/${{ env.bin-name }} ./${{ env.bin-name }}-${{ matrix.target }}
- name: Chmod
run: chmod +x ./${{ env.bin-name }}-${{ matrix.target }}
- name: Hash
run: echo "$(coreutils sha256sum ./${{ env.bin-name }}-${{ matrix.target }})" > ${{ matrix.target }}.sha256
- name: Artifact
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.target }}
path: |
${{ env.bin-name }}-${{ matrix.target }}
${{ matrix.target }}.sha256
apple-darwin:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-13
- target: aarch64-apple-darwin
os: macos-14
runs-on: ${{ matrix.os }}
needs: [ check-fmt, clippy, cargo-hack, cargo-msrv, cargo-deny ]
steps:
- uses: actions/checkout@v4
- name: Update Rust and add target
run: |
rustup update
rustc --version
rustup target add ${{ matrix.target }}
- uses: cargo-prebuilt/cargo-prebuilt-action@v3
with:
pkgs: cargo-auditable,coreutils
- uses: Swatinem/rust-cache@v2
if: ${{ env.cache == 'true' }}
- name: Build
run: cargo auditable build --verbose --workspace --release --locked --target ${{ matrix.target }} ${{ env.feature-set }}
- name: Run tests
if: ${{ matrix.can-test }}
run: |
BIN_LOC="./target/${{ matrix.target }}/release/${{ env.bin-name }}" ./test/_test.sh
- name: Rename
run: cp ./target/${{ matrix.target }}/release/${{ env.bin-name }} ./${{ env.bin-name }}-${{ matrix.target }}
- name: Chmod
run: chmod +x ./${{ env.bin-name }}-${{ matrix.target }}
- name: Hash
run: echo "$(coreutils sha256sum ./${{ env.bin-name }}-${{ matrix.target }})" > ${{ matrix.target }}.sha256
- name: Artifact
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.target }}
path: |
${{ env.bin-name }}-${{ matrix.target }}
${{ matrix.target }}.sha256
pc-windows-msvc:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc
can-test: true
- target: aarch64-pc-windows-msvc
can-test: false
runs-on: windows-latest
needs: [ check-fmt, clippy, cargo-hack, cargo-msrv, cargo-deny ]
steps:
- uses: actions/checkout@v4
- name: Update Rust and add target
run: |
rustup update
rustc --version
rustup target add ${{ matrix.target }}
- uses: cargo-prebuilt/cargo-prebuilt-action@v3
with:
pkgs: cargo-auditable,coreutils
- uses: Swatinem/rust-cache@v2
if: ${{ env.cache == 'true' }}
- name: Build
run: cargo auditable build --verbose --workspace --release --locked --target ${{ matrix.target }} ${{ env.feature-set }}
- name: Rename
run: cp ./target/${{ matrix.target }}/release/${{ env.bin-name }}.exe ./${{ env.bin-name }}-${{ matrix.target }}.exe
- name: Hash
run: echo "$(coreutils sha256sum ./${{ env.bin-name }}-${{ matrix.target }}.exe)" > ${{ matrix.target }}.sha256
- name: Artifact
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.target }}
path: |
${{ env.bin-name }}-${{ matrix.target }}.exe
${{ matrix.target }}.sha256