1
- # Copyright 2022-2023, axodotdev
1
+ # This file was autogenerated by dist: https://opensource.axo.dev/cargo-dist/
2
+ #
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
- # * on success, uploads the artifacts to a Github Release
11
+ # * on success, uploads the artifacts to a GitHub Release
10
12
#
11
- # Note that the Github Release will be created with a generated
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
+ " contents " : " write"
18
19
19
20
# This task will run whenever you push a git tag that looks like a version
20
21
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -23,30 +24,30 @@ permissions:
23
24
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
24
25
#
25
26
# If PACKAGE_NAME is specified, then the announcement will be for that
26
- # package (erroring out if it doesn't have the given version or isn't cargo- dist-able).
27
+ # package (erroring out if it doesn't have the given version or isn't dist-able).
27
28
#
28
29
# If PACKAGE_NAME isn't specified, then the announcement will be for all
29
- # (cargo- dist-able) packages in the workspace with that version (this mode is
30
+ # (dist-able) packages in the workspace with that version (this mode is
30
31
# intended for workspaces with only one dist-able package, or with all dist-able
31
32
# packages versioned/released in lockstep).
32
33
#
33
34
# If you push multiple tags at once, separate instances of this workflow will
34
- # spin up, creating an independent announcement for each one. However Github
35
+ # spin up, creating an independent announcement for each one. However, GitHub
35
36
# will hard limit this to 3 tags per commit, as it will assume more tags is a
36
37
# mistake.
37
38
#
38
39
# If there's a prerelease-style suffix to the version, then the release(s)
39
40
# will be marked as a prerelease.
40
41
on :
42
+ pull_request :
41
43
push :
42
44
tags :
43
45
- ' **[0-9]+.[0-9]+.[0-9]+*'
44
- pull_request :
45
46
46
47
jobs :
47
- # Run 'cargo dist plan' (or host) to determine what tasks we need to do
48
+ # Run 'dist plan' (or host) to determine what tasks we need to do
48
49
plan :
49
- runs-on : ubuntu-latest
50
+ runs-on : " ubuntu-20.04 "
50
51
outputs :
51
52
val : ${{ steps.plan.outputs.manifest }}
52
53
tag : ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -58,20 +59,25 @@ jobs:
58
59
- uses : actions/checkout@v4
59
60
with :
60
61
submodules : recursive
61
- - name : Install cargo- dist
62
+ - name : Install dist
62
63
# we specify bash to get pipefail; it guards against the `curl` command
63
64
# failing. otherwise `sh` won't catch that `curl` returned non-0
64
65
shell : bash
65
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.1/cargo-dist-installer.sh | sh"
66
+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.25.1/cargo-dist-installer.sh | sh"
67
+ - name : Cache dist
68
+ uses : actions/upload-artifact@v4
69
+ with :
70
+ name : cargo-dist-cache
71
+ path : ~/.cargo/bin/dist
66
72
# sure would be cool if github gave us proper conditionals...
67
73
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
68
74
# functionality based on whether this is a pull_request, and whether it's from a fork.
69
75
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
70
76
# but also really annoying to build CI around when it needs secrets to work right.)
71
77
- id : plan
72
78
run : |
73
- cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
74
- echo "cargo dist ran successfully"
79
+ dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
80
+ echo "dist ran successfully"
75
81
cat plan-dist-manifest.json
76
82
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
77
83
- name : " Upload dist-manifest.json"
@@ -89,12 +95,12 @@ jobs:
89
95
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') }}
90
96
strategy :
91
97
fail-fast : false
92
- # Target platforms/runners are computed by cargo- dist in create-release.
98
+ # Target platforms/runners are computed by dist in create-release.
93
99
# Each member of the matrix has the following arguments:
94
100
#
95
101
# - runner: the github runner
96
- # - dist-args: cli flags to pass to cargo dist
97
- # - install-dist: expression to run to install cargo- dist on the runner
102
+ # - dist-args: cli flags to pass to dist
103
+ # - install-dist: expression to run to install dist on the runner
98
104
#
99
105
# Typically there will be:
100
106
# - 1 "global" task that builds universal installers
@@ -105,11 +111,13 @@ jobs:
105
111
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
106
112
BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
107
113
steps :
114
+ - name : enable windows longpaths
115
+ run : |
116
+ git config --global core.longpaths true
108
117
- uses : actions/checkout@v4
109
118
with :
110
119
submodules : recursive
111
- - uses : swatinem/rust-cache@v2
112
- - name : Install cargo-dist
120
+ - name : Install dist
113
121
run : ${{ matrix.install_dist }}
114
122
# Get the dist-manifest
115
123
- name : Fetch local artifacts
@@ -124,8 +132,8 @@ jobs:
124
132
- name : Build artifacts
125
133
run : |
126
134
# Actually do builds and make zips and whatnot
127
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
128
- echo "cargo dist ran successfully"
135
+ dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
136
+ echo "dist ran successfully"
129
137
- id : cargo-dist
130
138
name : Post-build
131
139
# We force bash here just because github makes it really hard to get values up
@@ -135,7 +143,7 @@ jobs:
135
143
run : |
136
144
# Parse out what we just built and upload it to scratch storage
137
145
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
138
- jq --raw-output ".artifacts[]?.path | select( . != null ) " dist-manifest.json >> "$GITHUB_OUTPUT"
146
+ jq --raw-output ".upload_files[] " dist-manifest.json >> "$GITHUB_OUTPUT"
139
147
echo "EOF" >> "$GITHUB_OUTPUT"
140
148
141
149
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -170,9 +178,12 @@ jobs:
170
178
- uses : actions/checkout@v4
171
179
with :
172
180
submodules : recursive
173
- - name : Install cargo-dist
174
- shell : bash
175
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.1/cargo-dist-installer.sh | sh"
181
+ - name : Install cached dist
182
+ uses : actions/download-artifact@v4
183
+ with :
184
+ name : cargo-dist-cache
185
+ path : ~/.cargo/bin/
186
+ - run : chmod +x ~/.cargo/bin/dist
176
187
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
177
188
- name : Fetch local artifacts
178
189
uses : actions/download-artifact@v4
@@ -183,12 +194,12 @@ jobs:
183
194
- id : cargo-dist
184
195
shell : bash
185
196
run : |
186
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
187
- echo "cargo dist ran successfully"
197
+ dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
198
+ echo "dist ran successfully"
188
199
189
200
# Parse out what we just built and upload it to scratch storage
190
201
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
191
- jq --raw-output ".artifacts[]?.path | select( . != null ) " dist-manifest.json >> "$GITHUB_OUTPUT"
202
+ jq --raw-output ".upload_files[] " dist-manifest.json >> "$GITHUB_OUTPUT"
192
203
echo "EOF" >> "$GITHUB_OUTPUT"
193
204
194
205
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -214,10 +225,11 @@ jobs:
214
225
needs :
215
226
- plan
216
227
- build-local-artifacts
228
+ - custom-build-linux-arm
217
229
- build-global-artifacts
218
230
- custom-build-linux-pkgs
219
231
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
220
- 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') }}
232
+ if : ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.custom- build-linux-pkgs.result == 'skipped' || needs.custom-build-linux-pkgs.result == 'success') && (needs.build- local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') && (needs.custom-build-linux-arm.result == 'skipped' || needs.custom-build-linux-arm .result == 'success') }}
221
233
env :
222
234
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
223
235
runs-on : " ubuntu-20.04"
@@ -227,20 +239,23 @@ jobs:
227
239
- uses : actions/checkout@v4
228
240
with :
229
241
submodules : recursive
230
- - name : Install cargo-dist
231
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.1/cargo-dist-installer.sh | sh"
242
+ - name : Install cached dist
243
+ uses : actions/download-artifact@v4
244
+ with :
245
+ name : cargo-dist-cache
246
+ path : ~/.cargo/bin/
247
+ - run : chmod +x ~/.cargo/bin/dist
232
248
# Fetch artifacts from scratch-storage
233
249
- name : Fetch artifacts
234
250
uses : actions/download-artifact@v4
235
251
with :
236
252
pattern : artifacts-*
237
253
path : target/distrib/
238
254
merge-multiple : true
239
- # This is a harmless no-op for Github Releases, hosting for that happens in "announce"
240
255
- id : host
241
256
shell : bash
242
257
run : |
243
- cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
258
+ dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
244
259
echo "artifacts uploaded and released successfully"
245
260
cat dist-manifest.json
246
261
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -250,6 +265,28 @@ jobs:
250
265
# Overwrite the previous copy
251
266
name : artifacts-dist-manifest
252
267
path : dist-manifest.json
268
+ # Create a GitHub Release while uploading all files to it
269
+ - name : " Download GitHub Artifacts"
270
+ uses : actions/download-artifact@v4
271
+ with :
272
+ pattern : artifacts-*
273
+ path : artifacts
274
+ merge-multiple : true
275
+ - name : Cleanup
276
+ run : |
277
+ # Remove the granular manifests
278
+ rm -f artifacts/*-dist-manifest.json
279
+ - name : Create GitHub Release
280
+ env :
281
+ PRERELEASE_FLAG : " ${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
282
+ ANNOUNCEMENT_TITLE : " ${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
283
+ ANNOUNCEMENT_BODY : " ${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
284
+ RELEASE_COMMIT : " ${{ github.sha }}"
285
+ run : |
286
+ # Write and read notes from a file to avoid quoting breaking things
287
+ echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
288
+
289
+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
253
290
254
291
publish-homebrew-formula :
255
292
needs :
@@ -268,7 +305,7 @@ jobs:
268
305
repository : " oscope-dev/homebrew-formulas"
269
306
token : ${{ secrets.HOMEBREW_TAP_TOKEN }}
270
307
# So we have access to the formula
271
- - name : Fetch local artifacts
308
+ - name : Fetch homebrew formulae
272
309
uses : actions/download-artifact@v4
273
310
with :
274
311
pattern : artifacts-*
@@ -286,12 +323,16 @@ jobs:
286
323
name=$(echo "$filename" | sed "s/\.rb$//")
287
324
version=$(echo "$release" | jq .app_version --raw-output)
288
325
326
+ export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
327
+ brew update
328
+ # We avoid reformatting user-provided data such as the app description and homepage.
329
+ brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
330
+
289
331
git add "Formula/${filename}"
290
332
git commit -m "${name} ${version}"
291
333
done
292
334
git push
293
335
294
- # Create a Github Release while uploading all files to it
295
336
announce :
296
337
needs :
297
338
- plan
@@ -308,24 +349,6 @@ jobs:
308
349
- uses : actions/checkout@v4
309
350
with :
310
351
submodules : recursive
311
- - name : " Download Github Artifacts"
312
- uses : actions/download-artifact@v4
313
- with :
314
- pattern : artifacts-*
315
- path : artifacts
316
- merge-multiple : true
317
- - name : Cleanup
318
- run : |
319
- # Remove the granular manifests
320
- rm -f artifacts/*-dist-manifest.json
321
- - name : Create Github Release
322
- uses : ncipollo/release-action@v1
323
- with :
324
- tag : ${{ needs.plan.outputs.tag }}
325
- name : ${{ fromJson(needs.host.outputs.val).announcement_title }}
326
- body : ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
327
- prerelease : ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
328
- artifacts : " artifacts/*"
329
352
330
353
custom-dotslash :
331
354
needs :
0 commit comments