1
+ # This file was autogenerated by dist: https://opensource.axo.dev/cargo-dist/
2
+ #
1
3
# Copyright 2022-2024, axodotdev
2
4
# SPDX-License-Identifier: MIT or Apache-2.0
3
5
#
4
6
# CI that:
5
7
#
6
8
# * checks for a Git Tag that looks like a release
7
- # * builds artifacts with cargo- dist (archives, installers, hashes)
9
+ # * builds artifacts with dist (archives, installers, hashes)
8
10
# * uploads those artifacts to temporary workflow zip
9
11
# * on success, uploads the artifacts to a GitHub Release
10
12
#
11
13
# Note that the GitHub Release will be created with a generated
12
14
# title/body based on your changelogs.
13
15
14
16
name : Release
15
-
16
17
permissions :
17
- contents : write
18
- id-token : write
19
- attestations : write
18
+ " attestations " : " write"
19
+ " contents " : " write"
20
+ " id-token " : " write"
20
21
21
22
# This task will run whenever you push a git tag that looks like a version
22
23
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -25,10 +26,10 @@ permissions:
25
26
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
26
27
#
27
28
# If PACKAGE_NAME is specified, then the announcement will be for that
28
- # package (erroring out if it doesn't have the given version or isn't cargo- dist-able).
29
+ # package (erroring out if it doesn't have the given version or isn't dist-able).
29
30
#
30
31
# If PACKAGE_NAME isn't specified, then the announcement will be for all
31
- # (cargo- dist-able) packages in the workspace with that version (this mode is
32
+ # (dist-able) packages in the workspace with that version (this mode is
32
33
# intended for workspaces with only one dist-able package, or with all dist-able
33
34
# packages versioned/released in lockstep).
34
35
#
46
47
- ' **[0-9]+.[0-9]+.[0-9]+*'
47
48
48
49
jobs :
49
- # Run 'cargo dist plan' (or host) to determine what tasks we need to do
50
+ # Run 'dist plan' (or host) to determine what tasks we need to do
50
51
plan :
51
52
runs-on : " ubuntu-20.04"
52
53
outputs :
@@ -60,20 +61,25 @@ jobs:
60
61
- uses : actions/checkout@v4
61
62
with :
62
63
submodules : recursive
63
- - name : Install cargo- dist
64
+ - name : Install dist
64
65
# we specify bash to get pipefail; it guards against the `curl` command
65
66
# failing. otherwise `sh` won't catch that `curl` returned non-0
66
67
shell : bash
67
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0/cargo-dist-installer.sh | sh"
68
+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.26.1/cargo-dist-installer.sh | sh"
69
+ - name : Cache dist
70
+ uses : actions/upload-artifact@v4
71
+ with :
72
+ name : cargo-dist-cache
73
+ path : ~/.cargo/bin/dist
68
74
# sure would be cool if github gave us proper conditionals...
69
75
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
70
76
# functionality based on whether this is a pull_request, and whether it's from a fork.
71
77
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
72
78
# but also really annoying to build CI around when it needs secrets to work right.)
73
79
- id : plan
74
80
run : |
75
- cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
76
- echo "cargo dist ran successfully"
81
+ dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
82
+ echo "dist ran successfully"
77
83
cat plan-dist-manifest.json
78
84
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
79
85
- name : " Upload dist-manifest.json"
@@ -91,18 +97,19 @@ jobs:
91
97
if : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
92
98
strategy :
93
99
fail-fast : false
94
- # Target platforms/runners are computed by cargo- dist in create-release.
100
+ # Target platforms/runners are computed by dist in create-release.
95
101
# Each member of the matrix has the following arguments:
96
102
#
97
103
# - runner: the github runner
98
- # - dist-args: cli flags to pass to cargo dist
99
- # - install-dist: expression to run to install cargo- dist on the runner
104
+ # - dist-args: cli flags to pass to dist
105
+ # - install-dist: expression to run to install dist on the runner
100
106
#
101
107
# Typically there will be:
102
108
# - 1 "global" task that builds universal installers
103
109
# - N "local" tasks that build each platform's binaries and platform-specific installers
104
110
matrix : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
105
111
runs-on : ${{ matrix.runner }}
112
+ container : ${{ matrix.container && matrix.container.image || null }}
106
113
env :
107
114
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
108
115
BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
@@ -113,12 +120,15 @@ jobs:
113
120
- uses : actions/checkout@v4
114
121
with :
115
122
submodules : recursive
116
- - uses : swatinem/rust-cache@v2
117
- with :
118
- key : ${{ join(matrix.targets, '-') }}
119
- cache-provider : ${{ matrix.cache_provider }}
120
- - name : Install cargo-dist
121
- run : ${{ matrix.install_dist }}
123
+ - name : Install Rust non-interactively if not already installed
124
+ if : ${{ matrix.container }}
125
+ run : |
126
+ if ! command -v cargo > /dev/null 2>&1; then
127
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
128
+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
129
+ fi
130
+ - name : Install dist
131
+ run : ${{ matrix.install_dist.run }}
122
132
# Get the dist-manifest
123
133
- name : Fetch local artifacts
124
134
uses : actions/download-artifact@v4
@@ -132,8 +142,8 @@ jobs:
132
142
- name : Build artifacts
133
143
run : |
134
144
# Actually do builds and make zips and whatnot
135
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
136
- echo "cargo dist ran successfully"
145
+ dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
146
+ echo "dist ran successfully"
137
147
- name : Attest
138
148
uses : actions/attest-build-provenance@v1
139
149
with :
@@ -147,7 +157,7 @@ jobs:
147
157
run : |
148
158
# Parse out what we just built and upload it to scratch storage
149
159
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
150
- jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
160
+ dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
151
161
echo "EOF" >> "$GITHUB_OUTPUT"
152
162
153
163
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -172,9 +182,12 @@ jobs:
172
182
- uses : actions/checkout@v4
173
183
with :
174
184
submodules : recursive
175
- - name : Install cargo-dist
176
- shell : bash
177
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0/cargo-dist-installer.sh | sh"
185
+ - name : Install cached dist
186
+ uses : actions/download-artifact@v4
187
+ with :
188
+ name : cargo-dist-cache
189
+ path : ~/.cargo/bin/
190
+ - run : chmod +x ~/.cargo/bin/dist
178
191
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
179
192
- name : Fetch local artifacts
180
193
uses : actions/download-artifact@v4
@@ -185,8 +198,8 @@ jobs:
185
198
- id : cargo-dist
186
199
shell : bash
187
200
run : |
188
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
189
- echo "cargo dist ran successfully"
201
+ dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
202
+ echo "dist ran successfully"
190
203
191
204
# Parse out what we just built and upload it to scratch storage
192
205
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -218,20 +231,23 @@ jobs:
218
231
- uses : actions/checkout@v4
219
232
with :
220
233
submodules : recursive
221
- - name : Install cargo-dist
222
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0/cargo-dist-installer.sh | sh"
234
+ - name : Install cached dist
235
+ uses : actions/download-artifact@v4
236
+ with :
237
+ name : cargo-dist-cache
238
+ path : ~/.cargo/bin/
239
+ - run : chmod +x ~/.cargo/bin/dist
223
240
# Fetch artifacts from scratch-storage
224
241
- name : Fetch artifacts
225
242
uses : actions/download-artifact@v4
226
243
with :
227
244
pattern : artifacts-*
228
245
path : target/distrib/
229
246
merge-multiple : true
230
- # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
231
247
- id : host
232
248
shell : bash
233
249
run : |
234
- cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
250
+ dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
235
251
echo "artifacts uploaded and released successfully"
236
252
cat dist-manifest.json
237
253
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -241,23 +257,7 @@ jobs:
241
257
# Overwrite the previous copy
242
258
name : artifacts-dist-manifest
243
259
path : dist-manifest.json
244
-
245
- # Create a GitHub Release while uploading all files to it
246
- announce :
247
- needs :
248
- - plan
249
- - host
250
- # use "always() && ..." to allow us to wait for all publish jobs while
251
- # still allowing individual publish jobs to skip themselves (for prereleases).
252
- # "host" however must run to completion, no skipping allowed!
253
- if : ${{ always() && needs.host.result == 'success' }}
254
- runs-on : " ubuntu-20.04"
255
- env :
256
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
257
- steps :
258
- - uses : actions/checkout@v4
259
- with :
260
- submodules : recursive
260
+ # Create a GitHub Release while uploading all files to it
261
261
- name : " Download GitHub Artifacts"
262
262
uses : actions/download-artifact@v4
263
263
with :
@@ -270,12 +270,28 @@ jobs:
270
270
rm -f artifacts/*-dist-manifest.json
271
271
- name : Create GitHub Release
272
272
env :
273
- PRERELEASE_FLAG : " ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease && '--prerelease' || '' }}"
274
- ANNOUNCEMENT_TITLE : " ${{ fromJson(needs.host.outputs.val).announcement_title }}"
275
- ANNOUNCEMENT_BODY : " ${{ fromJson(needs.host.outputs.val).announcement_github_body }}"
273
+ PRERELEASE_FLAG : " ${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
274
+ ANNOUNCEMENT_TITLE : " ${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
275
+ ANNOUNCEMENT_BODY : " ${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
276
+ RELEASE_COMMIT : " ${{ github.sha }}"
276
277
run : |
277
278
# Write and read notes from a file to avoid quoting breaking things
278
279
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
279
280
280
- gh release create "${{ needs.plan.outputs.tag }}" --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" $PRERELEASE_FLAG
281
- gh release upload "${{ needs.plan.outputs.tag }}" artifacts/*
281
+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
282
+
283
+ announce :
284
+ needs :
285
+ - plan
286
+ - host
287
+ # use "always() && ..." to allow us to wait for all publish jobs while
288
+ # still allowing individual publish jobs to skip themselves (for prereleases).
289
+ # "host" however must run to completion, no skipping allowed!
290
+ if : ${{ always() && needs.host.result == 'success' }}
291
+ runs-on : " ubuntu-20.04"
292
+ env :
293
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
294
+ steps :
295
+ - uses : actions/checkout@v4
296
+ with :
297
+ submodules : recursive
0 commit comments