1
+ # This file was autogenerated by dist: https://github.com/astral-sh/cargo-dist
2
+ #
1
3
# Copyright 2022-2024, axodotdev
4
+ # Copyright 2025 Astral Software Inc.
2
5
# SPDX-License-Identifier: MIT or Apache-2.0
3
6
#
4
7
# CI that:
5
8
#
6
9
# * checks for a Git Tag that looks like a release
7
- # * builds artifacts with cargo- dist (archives, installers, hashes)
10
+ # * builds artifacts with dist (archives, installers, hashes)
8
11
# * uploads those artifacts to temporary workflow zip
9
12
# * on success, uploads the artifacts to a GitHub Release
10
13
#
@@ -22,10 +25,10 @@ permissions:
22
25
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
23
26
#
24
27
# If PACKAGE_NAME is specified, then the announcement will be for that
25
- # package (erroring out if it doesn't have the given version or isn't cargo- dist-able).
28
+ # package (erroring out if it doesn't have the given version or isn't dist-able).
26
29
#
27
30
# If PACKAGE_NAME isn't specified, then the announcement will be for all
28
- # (cargo- dist-able) packages in the workspace with that version (this mode is
31
+ # (dist-able) packages in the workspace with that version (this mode is
29
32
# intended for workspaces with only one dist-able package, or with all dist-able
30
33
# packages versioned/released in lockstep).
31
34
#
43
46
- ' **[0-9]+.[0-9]+.[0-9]+*'
44
47
45
48
jobs :
46
- # Run 'cargo dist plan' (or host) to determine what tasks we need to do
49
+ # Run 'dist plan' (or host) to determine what tasks we need to do
47
50
plan :
48
- runs-on : " ubuntu-20 .04"
51
+ runs-on : " ubuntu-22 .04"
49
52
outputs :
50
53
val : ${{ steps.plan.outputs.manifest }}
51
54
tag : ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -56,26 +59,27 @@ jobs:
56
59
steps :
57
60
- uses : actions/checkout@v4
58
61
with :
62
+ persist-credentials : false
59
63
submodules : recursive
60
- - name : Install cargo- dist
64
+ - name : Install dist
61
65
# we specify bash to get pipefail; it guards against the `curl` command
62
66
# failing. otherwise `sh` won't catch that `curl` returned non-0
63
67
shell : bash
64
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev /cargo-dist/releases/download/v0.18.0 /cargo-dist-installer.sh | sh"
65
- - name : Cache cargo- dist
68
+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh /cargo-dist/releases/download/v0.28.4 /cargo-dist-installer.sh | sh"
69
+ - name : Cache dist
66
70
uses : actions/upload-artifact@v4
67
71
with :
68
72
name : cargo-dist-cache
69
- path : ~/.cargo/bin/cargo- dist
73
+ path : ~/.cargo/bin/dist
70
74
# sure would be cool if github gave us proper conditionals...
71
75
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
72
76
# functionality based on whether this is a pull_request, and whether it's from a fork.
73
77
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
74
78
# but also really annoying to build CI around when it needs secrets to work right.)
75
79
- id : plan
76
80
run : |
77
- cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
78
- 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"
79
83
cat plan-dist-manifest.json
80
84
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
81
85
- name : " Upload dist-manifest.json"
@@ -93,18 +97,19 @@ jobs:
93
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') }}
94
98
strategy :
95
99
fail-fast : false
96
- # Target platforms/runners are computed by cargo- dist in create-release.
100
+ # Target platforms/runners are computed by dist in create-release.
97
101
# Each member of the matrix has the following arguments:
98
102
#
99
103
# - runner: the github runner
100
- # - dist-args: cli flags to pass to cargo dist
101
- # - 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
102
106
#
103
107
# Typically there will be:
104
108
# - 1 "global" task that builds universal installers
105
109
# - N "local" tasks that build each platform's binaries and platform-specific installers
106
110
matrix : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
107
111
runs-on : ${{ matrix.runner }}
112
+ container : ${{ matrix.container && matrix.container.image || null }}
108
113
env :
109
114
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
110
115
BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
@@ -114,9 +119,17 @@ jobs:
114
119
git config --global core.longpaths true
115
120
- uses : actions/checkout@v4
116
121
with :
122
+ persist-credentials : false
117
123
submodules : recursive
118
- - name : Install cargo-dist
119
- run : ${{ matrix.install_dist }}
124
+ - name : Install Rust non-interactively if not already installed
125
+ if : ${{ matrix.container }}
126
+ run : |
127
+ if ! command -v cargo > /dev/null 2>&1; then
128
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
129
+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
130
+ fi
131
+ - name : Install dist
132
+ run : ${{ matrix.install_dist.run }}
120
133
# Get the dist-manifest
121
134
- name : Fetch local artifacts
122
135
uses : actions/download-artifact@v4
@@ -130,8 +143,8 @@ jobs:
130
143
- name : Build artifacts
131
144
run : |
132
145
# Actually do builds and make zips and whatnot
133
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
134
- echo "cargo dist ran successfully"
146
+ dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
147
+ echo "dist ran successfully"
135
148
- id : cargo-dist
136
149
name : Post-build
137
150
# We force bash here just because github makes it really hard to get values up
@@ -141,7 +154,7 @@ jobs:
141
154
run : |
142
155
# Parse out what we just built and upload it to scratch storage
143
156
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
144
- jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
157
+ dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
145
158
echo "EOF" >> "$GITHUB_OUTPUT"
146
159
147
160
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -158,20 +171,21 @@ jobs:
158
171
needs :
159
172
- plan
160
173
- build-local-artifacts
161
- runs-on : " ubuntu-20 .04"
174
+ runs-on : " ubuntu-22 .04"
162
175
env :
163
176
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
164
177
BUILD_MANIFEST_NAME : target/distrib/global-dist-manifest.json
165
178
steps :
166
179
- uses : actions/checkout@v4
167
180
with :
181
+ persist-credentials : false
168
182
submodules : recursive
169
- - name : Install cached cargo- dist
183
+ - name : Install cached dist
170
184
uses : actions/download-artifact@v4
171
185
with :
172
186
name : cargo-dist-cache
173
187
path : ~/.cargo/bin/
174
- - run : chmod +x ~/.cargo/bin/cargo- dist
188
+ - run : chmod +x ~/.cargo/bin/dist
175
189
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
176
190
- name : Fetch local artifacts
177
191
uses : actions/download-artifact@v4
@@ -182,8 +196,8 @@ jobs:
182
196
- id : cargo-dist
183
197
shell : bash
184
198
run : |
185
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
186
- echo "cargo dist ran successfully"
199
+ dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
200
+ echo "dist ran successfully"
187
201
188
202
# Parse out what we just built and upload it to scratch storage
189
203
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -208,19 +222,20 @@ jobs:
208
222
if : ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
209
223
env :
210
224
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
211
- runs-on : " ubuntu-20 .04"
225
+ runs-on : " ubuntu-22 .04"
212
226
outputs :
213
227
val : ${{ steps.host.outputs.manifest }}
214
228
steps :
215
229
- uses : actions/checkout@v4
216
230
with :
231
+ persist-credentials : false
217
232
submodules : recursive
218
- - name : Install cached cargo- dist
233
+ - name : Install cached dist
219
234
uses : actions/download-artifact@v4
220
235
with :
221
236
name : cargo-dist-cache
222
237
path : ~/.cargo/bin/
223
- - run : chmod +x ~/.cargo/bin/cargo- dist
238
+ - run : chmod +x ~/.cargo/bin/dist
224
239
# Fetch artifacts from scratch-storage
225
240
- name : Fetch artifacts
226
241
uses : actions/download-artifact@v4
@@ -231,7 +246,7 @@ jobs:
231
246
- id : host
232
247
shell : bash
233
248
run : |
234
- cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
249
+ dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
235
250
echo "artifacts uploaded and released successfully"
236
251
cat dist-manifest.json
237
252
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -264,59 +279,19 @@ jobs:
264
279
265
280
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
266
281
267
- publish-homebrew-formula :
268
- needs :
269
- - plan
270
- - host
271
- runs-on : " ubuntu-20.04"
272
- env :
273
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
274
- PLAN : ${{ needs.plan.outputs.val }}
275
- GITHUB_USER : " axo bot"
276
-
277
- if : ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
278
- steps :
279
- - uses : actions/checkout@v4
280
- with :
281
- repository : " shellrow/homebrew-tap-nrev"
282
- token : ${{ secrets.HOMEBREW_TAP_TOKEN }}
283
- # So we have access to the formula
284
- - name : Fetch homebrew formulae
285
- uses : actions/download-artifact@v4
286
- with :
287
- pattern : artifacts-*
288
- path : Formula/
289
- merge-multiple : true
290
- # This is extra complex because you can make your Formula name not match your app name
291
- # so we need to find releases with a *.rb file, and publish with that filename.
292
- - name : Commit formula files
293
- run : |
294
- git config --global user.name "${GITHUB_USER}"
295
- git config --global user.email "${GITHUB_EMAIL}"
296
-
297
- for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do
298
- filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output)
299
- name=$(echo "$filename" | sed "s/\.rb$//")
300
- version=$(echo "$release" | jq .app_version --raw-output)
301
-
302
- git add "Formula/${filename}"
303
- git commit -m "${name} ${version}"
304
- done
305
- git push
306
-
307
282
announce :
308
283
needs :
309
284
- plan
310
285
- host
311
- - publish-homebrew-formula
312
286
# use "always() && ..." to allow us to wait for all publish jobs while
313
287
# still allowing individual publish jobs to skip themselves (for prereleases).
314
288
# "host" however must run to completion, no skipping allowed!
315
- if : ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
316
- runs-on : " ubuntu-20 .04"
289
+ if : ${{ always() && needs.host.result == 'success' }}
290
+ runs-on : " ubuntu-22 .04"
317
291
env :
318
292
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
319
293
steps :
320
294
- uses : actions/checkout@v4
321
295
with :
296
+ persist-credentials : false
322
297
submodules : recursive
0 commit comments