1
- # Copyright 2022-2023 , axodotdev
1
+ # Copyright 2022-2024 , axodotdev
2
2
# SPDX-License-Identifier: MIT or Apache-2.0
3
3
#
4
4
# CI that:
5
5
#
6
6
# * checks for a Git Tag that looks like a release
7
7
# * builds artifacts with cargo-dist (archives, installers, hashes)
8
8
# * uploads those artifacts to temporary workflow zip
9
- # * on success, uploads the artifacts to a Github Release
9
+ # * on success, uploads the artifacts to a GitHub Release
10
10
#
11
- # Note that the Github Release will be created with a generated
11
+ # Note that the GitHub Release will be created with a generated
12
12
# title/body based on your changelogs.
13
13
14
14
name : Release
15
-
16
15
permissions :
17
- contents : write
16
+ " contents " : " write"
18
17
19
18
# This task will run whenever you push a git tag that looks like a version
20
19
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -31,22 +30,22 @@ permissions:
31
30
# packages versioned/released in lockstep).
32
31
#
33
32
# 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
33
+ # spin up, creating an independent announcement for each one. However, GitHub
35
34
# will hard limit this to 3 tags per commit, as it will assume more tags is a
36
35
# mistake.
37
36
#
38
37
# If there's a prerelease-style suffix to the version, then the release(s)
39
38
# will be marked as a prerelease.
40
39
on :
40
+ pull_request :
41
41
push :
42
42
tags :
43
43
- ' **[0-9]+.[0-9]+.[0-9]+*'
44
- pull_request :
45
44
46
45
jobs :
47
46
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
48
47
plan :
49
- runs-on : ubuntu-latest
48
+ runs-on : " ubuntu-20.04 "
50
49
outputs :
51
50
val : ${{ steps.plan.outputs.manifest }}
52
51
tag : ${{ !github.event.pull_request && github.ref_name || '' }}
62
61
# we specify bash to get pipefail; it guards against the `curl` command
63
62
# failing. otherwise `sh` won't catch that `curl` returned non-0
64
63
shell : bash
65
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh"
64
+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.21.0/cargo-dist-installer.sh | sh"
65
+ - name : Cache cargo-dist
66
+ uses : actions/upload-artifact@v4
67
+ with :
68
+ name : cargo-dist-cache
69
+ path : ~/.cargo/bin/cargo-dist
66
70
# sure would be cool if github gave us proper conditionals...
67
71
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
68
72
# functionality based on whether this is a pull_request, and whether it's from a fork.
@@ -105,10 +109,12 @@ jobs:
105
109
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
106
110
BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
107
111
steps :
112
+ - name : enable windows longpaths
113
+ run : |
114
+ git config --global core.longpaths true
108
115
- uses : actions/checkout@v4
109
116
with :
110
117
submodules : recursive
111
- - uses : swatinem/rust-cache@v2
112
118
- name : Install cargo-dist
113
119
run : ${{ matrix.install_dist }}
114
120
# Get the dist-manifest
@@ -135,7 +141,7 @@ jobs:
135
141
run : |
136
142
# Parse out what we just built and upload it to scratch storage
137
143
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
138
- jq --raw-output ".artifacts[]?.path | select( . != null ) " dist-manifest.json >> "$GITHUB_OUTPUT"
144
+ jq --raw-output ".upload_files[] " dist-manifest.json >> "$GITHUB_OUTPUT"
139
145
echo "EOF" >> "$GITHUB_OUTPUT"
140
146
141
147
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -160,9 +166,12 @@ jobs:
160
166
- uses : actions/checkout@v4
161
167
with :
162
168
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.12.0/cargo-dist-installer.sh | sh"
169
+ - name : Install cached cargo-dist
170
+ uses : actions/download-artifact@v4
171
+ with :
172
+ name : cargo-dist-cache
173
+ path : ~/.cargo/bin/
174
+ - run : chmod +x ~/.cargo/bin/cargo-dist
166
175
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
167
176
- name : Fetch local artifacts
168
177
uses : actions/download-artifact@v4
@@ -178,7 +187,7 @@ jobs:
178
187
179
188
# Parse out what we just built and upload it to scratch storage
180
189
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
181
- jq --raw-output ".artifacts[]?.path | select( . != null ) " dist-manifest.json >> "$GITHUB_OUTPUT"
190
+ jq --raw-output ".upload_files[] " dist-manifest.json >> "$GITHUB_OUTPUT"
182
191
echo "EOF" >> "$GITHUB_OUTPUT"
183
192
184
193
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -206,16 +215,19 @@ jobs:
206
215
- uses : actions/checkout@v4
207
216
with :
208
217
submodules : recursive
209
- - name : Install cargo-dist
210
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh"
218
+ - name : Install cached cargo-dist
219
+ uses : actions/download-artifact@v4
220
+ with :
221
+ name : cargo-dist-cache
222
+ path : ~/.cargo/bin/
223
+ - run : chmod +x ~/.cargo/bin/cargo-dist
211
224
# Fetch artifacts from scratch-storage
212
225
- name : Fetch artifacts
213
226
uses : actions/download-artifact@v4
214
227
with :
215
228
pattern : artifacts-*
216
229
path : target/distrib/
217
230
merge-multiple : true
218
- # This is a harmless no-op for Github Releases, hosting for that happens in "announce"
219
231
- id : host
220
232
shell : bash
221
233
run : |
@@ -229,8 +241,29 @@ jobs:
229
241
# Overwrite the previous copy
230
242
name : artifacts-dist-manifest
231
243
path : dist-manifest.json
244
+ # Create a GitHub Release while uploading all files to it
245
+ - name : " Download GitHub Artifacts"
246
+ uses : actions/download-artifact@v4
247
+ with :
248
+ pattern : artifacts-*
249
+ path : artifacts
250
+ merge-multiple : true
251
+ - name : Cleanup
252
+ run : |
253
+ # Remove the granular manifests
254
+ rm -f artifacts/*-dist-manifest.json
255
+ - name : Create GitHub Release
256
+ env :
257
+ PRERELEASE_FLAG : " ${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
258
+ ANNOUNCEMENT_TITLE : " ${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
259
+ ANNOUNCEMENT_BODY : " ${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
260
+ RELEASE_COMMIT : " ${{ github.sha }}"
261
+ run : |
262
+ # Write and read notes from a file to avoid quoting breaking things
263
+ echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
264
+
265
+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
232
266
233
- # Create a Github Release while uploading all files to it
234
267
announce :
235
268
needs :
236
269
- plan
@@ -246,21 +279,3 @@ jobs:
246
279
- uses : actions/checkout@v4
247
280
with :
248
281
submodules : recursive
249
- - name : " Download Github Artifacts"
250
- uses : actions/download-artifact@v4
251
- with :
252
- pattern : artifacts-*
253
- path : artifacts
254
- merge-multiple : true
255
- - name : Cleanup
256
- run : |
257
- # Remove the granular manifests
258
- rm -f artifacts/*-dist-manifest.json
259
- - name : Create Github Release
260
- uses : ncipollo/release-action@v1
261
- with :
262
- tag : ${{ needs.plan.outputs.tag }}
263
- name : ${{ fromJson(needs.host.outputs.val).announcement_title }}
264
- body : ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
265
- prerelease : ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
266
- artifacts : " artifacts/*"
0 commit comments