1
- # Copyright 2022-2023, axodotdev
1
+ # This file was autogenerated by cargo-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
9
# * builds artifacts with cargo-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.
@@ -31,22 +32,22 @@ permissions:
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
48
# Run 'cargo 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 || '' }}
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.23.0/cargo-dist-installer.sh | sh"
67
+ - name : Cache cargo-dist
68
+ uses : actions/upload-artifact@v4
69
+ with :
70
+ name : cargo-dist-cache
71
+ path : ~/.cargo/bin/cargo-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.
@@ -105,10 +111,12 @@ 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
120
- name : Install cargo-dist
113
121
run : ${{ matrix.install_dist }}
114
122
# Get the dist-manifest
@@ -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"
@@ -160,9 +168,12 @@ jobs:
160
168
- uses : actions/checkout@v4
161
169
with :
162
170
submodules : recursive
163
- - name : Install cargo-dist
164
- shell : bash
165
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.1/cargo-dist-installer.sh | sh"
171
+ - name : Install cached cargo-dist
172
+ uses : actions/download-artifact@v4
173
+ with :
174
+ name : cargo-dist-cache
175
+ path : ~/.cargo/bin/
176
+ - run : chmod +x ~/.cargo/bin/cargo-dist
166
177
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
167
178
- name : Fetch local artifacts
168
179
uses : actions/download-artifact@v4
@@ -178,7 +189,7 @@ jobs:
178
189
179
190
# Parse out what we just built and upload it to scratch storage
180
191
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
181
- jq --raw-output ".artifacts[]?.path | select( . != null ) " dist-manifest.json >> "$GITHUB_OUTPUT"
192
+ jq --raw-output ".upload_files[] " dist-manifest.json >> "$GITHUB_OUTPUT"
182
193
echo "EOF" >> "$GITHUB_OUTPUT"
183
194
184
195
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -206,16 +217,19 @@ jobs:
206
217
- uses : actions/checkout@v4
207
218
with :
208
219
submodules : recursive
209
- - name : Install cargo-dist
210
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.1/cargo-dist-installer.sh | sh"
220
+ - name : Install cached cargo-dist
221
+ uses : actions/download-artifact@v4
222
+ with :
223
+ name : cargo-dist-cache
224
+ path : ~/.cargo/bin/
225
+ - run : chmod +x ~/.cargo/bin/cargo-dist
211
226
# Fetch artifacts from scratch-storage
212
227
- name : Fetch artifacts
213
228
uses : actions/download-artifact@v4
214
229
with :
215
230
pattern : artifacts-*
216
231
path : target/distrib/
217
232
merge-multiple : true
218
- # This is a harmless no-op for Github Releases, hosting for that happens in "announce"
219
233
- id : host
220
234
shell : bash
221
235
run : |
@@ -229,6 +243,28 @@ jobs:
229
243
# Overwrite the previous copy
230
244
name : artifacts-dist-manifest
231
245
path : dist-manifest.json
246
+ # Create a GitHub Release while uploading all files to it
247
+ - name : " Download GitHub Artifacts"
248
+ uses : actions/download-artifact@v4
249
+ with :
250
+ pattern : artifacts-*
251
+ path : artifacts
252
+ merge-multiple : true
253
+ - name : Cleanup
254
+ run : |
255
+ # Remove the granular manifests
256
+ rm -f artifacts/*-dist-manifest.json
257
+ - name : Create GitHub Release
258
+ env :
259
+ PRERELEASE_FLAG : " ${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
260
+ ANNOUNCEMENT_TITLE : " ${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
261
+ ANNOUNCEMENT_BODY : " ${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
262
+ RELEASE_COMMIT : " ${{ github.sha }}"
263
+ run : |
264
+ # Write and read notes from a file to avoid quoting breaking things
265
+ echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
266
+
267
+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
232
268
233
269
publish-homebrew-formula :
234
270
needs :
@@ -247,7 +283,7 @@ jobs:
247
283
repository : " ynqa/homebrew-tap"
248
284
token : ${{ secrets.HOMEBREW_TAP_TOKEN }}
249
285
# So we have access to the formula
250
- - name : Fetch local artifacts
286
+ - name : Fetch homebrew formulae
251
287
uses : actions/download-artifact@v4
252
288
with :
253
289
pattern : artifacts-*
@@ -265,12 +301,16 @@ jobs:
265
301
name=$(echo "$filename" | sed "s/\.rb$//")
266
302
version=$(echo "$release" | jq .app_version --raw-output)
267
303
304
+ export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
305
+ brew update
306
+ # We avoid reformatting user-provided data such as the app description and homepage.
307
+ brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
308
+
268
309
git add "Formula/${filename}"
269
310
git commit -m "${name} ${version}"
270
311
done
271
312
git push
272
313
273
- # Create a Github Release while uploading all files to it
274
314
announce :
275
315
needs :
276
316
- plan
@@ -287,21 +327,3 @@ jobs:
287
327
- uses : actions/checkout@v4
288
328
with :
289
329
submodules : recursive
290
- - name : " Download Github Artifacts"
291
- uses : actions/download-artifact@v4
292
- with :
293
- pattern : artifacts-*
294
- path : artifacts
295
- merge-multiple : true
296
- - name : Cleanup
297
- run : |
298
- # Remove the granular manifests
299
- rm -f artifacts/*-dist-manifest.json
300
- - name : Create Github Release
301
- uses : ncipollo/release-action@v1
302
- with :
303
- tag : ${{ needs.plan.outputs.tag }}
304
- name : ${{ fromJson(needs.host.outputs.val).announcement_title }}
305
- body : ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
306
- prerelease : ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
307
- artifacts : " artifacts/*"
0 commit comments