1212# title/body based on your changelogs.
1313
1414name : Release
15-
1615permissions :
17- contents : write
16+ " contents " : " write"
1817
1918# This task will run whenever you push a git tag that looks like a version
2019# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -38,15 +37,15 @@ permissions:
3837# If there's a prerelease-style suffix to the version, then the release(s)
3938# will be marked as a prerelease.
4039on :
40+ pull_request :
4141 push :
4242 tags :
4343 - ' **[0-9]+.[0-9]+.[0-9]+*'
44- pull_request :
4544
4645jobs :
4746 # Run 'cargo dist plan' (or host) to determine what tasks we need to do
4847 plan :
49- runs-on : ubuntu-latest
48+ runs-on : " ubuntu-20.04 "
5049 outputs :
5150 val : ${{ steps.plan.outputs.manifest }}
5251 tag : ${{ !github.event.pull_request && github.ref_name || '' }}
6261 # we specify bash to get pipefail; it guards against the `curl` command
6362 # failing. otherwise `sh` won't catch that `curl` returned non-0
6463 shell : bash
65- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.2/cargo-dist-installer.sh | sh"
64+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.19.1/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
6670 # sure would be cool if github gave us proper conditionals...
6771 # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
6872 # functionality based on whether this is a pull_request, and whether it's from a fork.
@@ -105,12 +109,12 @@ jobs:
105109 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
106110 BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
107111 steps :
112+ - name : enable windows longpaths
113+ run : |
114+ git config --global core.longpaths true
108115 - uses : actions/checkout@v4
109116 with :
110117 submodules : recursive
111- - uses : swatinem/rust-cache@v2
112- with :
113- key : ${{ join(matrix.targets, '-') }}
114118 - name : Install cargo-dist
115119 run : ${{ matrix.install_dist }}
116120 # Get the dist-manifest
@@ -162,9 +166,12 @@ jobs:
162166 - uses : actions/checkout@v4
163167 with :
164168 submodules : recursive
165- - name : Install cargo-dist
166- shell : bash
167- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.2/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
168175 # Get all the local artifacts for the global tasks to use (for e.g. checksums)
169176 - name : Fetch local artifacts
170177 uses : actions/download-artifact@v4
@@ -208,16 +215,19 @@ jobs:
208215 - uses : actions/checkout@v4
209216 with :
210217 submodules : recursive
211- - name : Install cargo-dist
212- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.2/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
213224 # Fetch artifacts from scratch-storage
214225 - name : Fetch artifacts
215226 uses : actions/download-artifact@v4
216227 with :
217228 pattern : artifacts-*
218229 path : target/distrib/
219230 merge-multiple : true
220- # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
221231 - id : host
222232 shell : bash
223233 run : |
@@ -231,8 +241,29 @@ jobs:
231241 # Overwrite the previous copy
232242 name : artifacts-dist-manifest
233243 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/*
234266
235- # Create a GitHub Release while uploading all files to it
236267 announce :
237268 needs :
238269 - plan
@@ -248,21 +279,3 @@ jobs:
248279 - uses : actions/checkout@v4
249280 with :
250281 submodules : recursive
251- - name : " Download GitHub Artifacts"
252- uses : actions/download-artifact@v4
253- with :
254- pattern : artifacts-*
255- path : artifacts
256- merge-multiple : true
257- - name : Cleanup
258- run : |
259- # Remove the granular manifests
260- rm -f artifacts/*-dist-manifest.json
261- - name : Create GitHub Release
262- uses : ncipollo/release-action@v1
263- with :
264- tag : ${{ needs.plan.outputs.tag }}
265- name : ${{ fromJson(needs.host.outputs.val).announcement_title }}
266- body : ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
267- prerelease : ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
268- artifacts : " artifacts/*"
0 commit comments