1
+ # This file was autogenerated by dist: https://opensource.axo.dev/cargo-dist/
2
+ #
1
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
11
# * on success, uploads the artifacts to a GitHub Release
10
12
#
11
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,10 +24,10 @@ 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
#
43
44
- ' **[0-9]+.[0-9]+.[0-9]+*'
44
45
45
46
jobs :
46
- # Run 'cargo dist plan' (or host) to determine what tasks we need to do
47
+ # Run 'dist plan' (or host) to determine what tasks we need to do
47
48
plan :
48
- runs-on : ubuntu-latest
49
+ runs-on : " ubuntu-20.04 "
49
50
outputs :
50
51
val : ${{ steps.plan.outputs.manifest }}
51
52
tag : ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -57,20 +58,25 @@ jobs:
57
58
- uses : actions/checkout@v4
58
59
with :
59
60
submodules : recursive
60
- - name : Install cargo- dist
61
+ - name : Install dist
61
62
# we specify bash to get pipefail; it guards against the `curl` command
62
63
# failing. otherwise `sh` won't catch that `curl` returned non-0
63
64
shell : bash
64
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.2/cargo-dist-installer.sh | sh"
65
+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.27.0/cargo-dist-installer.sh | sh"
66
+ - name : Cache dist
67
+ uses : actions/upload-artifact@v4
68
+ with :
69
+ name : cargo-dist-cache
70
+ path : ~/.cargo/bin/dist
65
71
# sure would be cool if github gave us proper conditionals...
66
72
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
67
73
# functionality based on whether this is a pull_request, and whether it's from a fork.
68
74
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
69
75
# but also really annoying to build CI around when it needs secrets to work right.)
70
76
- id : plan
71
77
run : |
72
- cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
73
- echo "cargo dist ran successfully"
78
+ dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
79
+ echo "dist ran successfully"
74
80
cat plan-dist-manifest.json
75
81
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
76
82
- name : " Upload dist-manifest.json"
@@ -88,30 +94,38 @@ jobs:
88
94
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') }}
89
95
strategy :
90
96
fail-fast : false
91
- # Target platforms/runners are computed by cargo- dist in create-release.
97
+ # Target platforms/runners are computed by dist in create-release.
92
98
# Each member of the matrix has the following arguments:
93
99
#
94
100
# - runner: the github runner
95
- # - dist-args: cli flags to pass to cargo dist
96
- # - install-dist: expression to run to install cargo- dist on the runner
101
+ # - dist-args: cli flags to pass to dist
102
+ # - install-dist: expression to run to install dist on the runner
97
103
#
98
104
# Typically there will be:
99
105
# - 1 "global" task that builds universal installers
100
106
# - N "local" tasks that build each platform's binaries and platform-specific installers
101
107
matrix : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
102
108
runs-on : ${{ matrix.runner }}
109
+ container : ${{ matrix.container && matrix.container.image || null }}
103
110
env :
104
111
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
105
112
BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
106
113
steps :
114
+ - name : enable windows longpaths
115
+ run : |
116
+ git config --global core.longpaths true
107
117
- uses : actions/checkout@v4
108
118
with :
109
119
submodules : recursive
110
- - uses : swatinem/rust-cache@v2
111
- with :
112
- key : ${{ join(matrix.targets, '-') }}
113
- - name : Install cargo-dist
114
- run : ${{ matrix.install_dist }}
120
+ - name : Install Rust non-interactively if not already installed
121
+ if : ${{ matrix.container }}
122
+ run : |
123
+ if ! command -v cargo > /dev/null 2>&1; then
124
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
125
+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
126
+ fi
127
+ - name : Install dist
128
+ run : ${{ matrix.install_dist.run }}
115
129
# Get the dist-manifest
116
130
- name : Fetch local artifacts
117
131
uses : actions/download-artifact@v4
@@ -125,8 +139,8 @@ jobs:
125
139
- name : Build artifacts
126
140
run : |
127
141
# Actually do builds and make zips and whatnot
128
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
129
- echo "cargo dist ran successfully"
142
+ dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
143
+ echo "dist ran successfully"
130
144
- id : cargo-dist
131
145
name : Post-build
132
146
# We force bash here just because github makes it really hard to get values up
@@ -136,7 +150,7 @@ jobs:
136
150
run : |
137
151
# Parse out what we just built and upload it to scratch storage
138
152
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
139
- jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
153
+ dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
140
154
echo "EOF" >> "$GITHUB_OUTPUT"
141
155
142
156
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -161,9 +175,12 @@ jobs:
161
175
- uses : actions/checkout@v4
162
176
with :
163
177
submodules : recursive
164
- - name : Install cargo-dist
165
- shell : bash
166
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.2/cargo-dist-installer.sh | sh"
178
+ - name : Install cached dist
179
+ uses : actions/download-artifact@v4
180
+ with :
181
+ name : cargo-dist-cache
182
+ path : ~/.cargo/bin/
183
+ - run : chmod +x ~/.cargo/bin/dist
167
184
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
168
185
- name : Fetch local artifacts
169
186
uses : actions/download-artifact@v4
@@ -174,8 +191,8 @@ jobs:
174
191
- id : cargo-dist
175
192
shell : bash
176
193
run : |
177
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
178
- echo "cargo dist ran successfully"
194
+ dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
195
+ echo "dist ran successfully"
179
196
180
197
# Parse out what we just built and upload it to scratch storage
181
198
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -207,20 +224,23 @@ jobs:
207
224
- uses : actions/checkout@v4
208
225
with :
209
226
submodules : recursive
210
- - name : Install cargo-dist
211
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.2/cargo-dist-installer.sh | sh"
227
+ - name : Install cached dist
228
+ uses : actions/download-artifact@v4
229
+ with :
230
+ name : cargo-dist-cache
231
+ path : ~/.cargo/bin/
232
+ - run : chmod +x ~/.cargo/bin/dist
212
233
# Fetch artifacts from scratch-storage
213
234
- name : Fetch artifacts
214
235
uses : actions/download-artifact@v4
215
236
with :
216
237
pattern : artifacts-*
217
238
path : target/distrib/
218
239
merge-multiple : true
219
- # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
220
240
- id : host
221
241
shell : bash
222
242
run : |
223
- cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
243
+ dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
224
244
echo "artifacts uploaded and released successfully"
225
245
cat dist-manifest.json
226
246
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -230,8 +250,29 @@ jobs:
230
250
# Overwrite the previous copy
231
251
name : artifacts-dist-manifest
232
252
path : dist-manifest.json
253
+ # Create a GitHub Release while uploading all files to it
254
+ - name : " Download GitHub Artifacts"
255
+ uses : actions/download-artifact@v4
256
+ with :
257
+ pattern : artifacts-*
258
+ path : artifacts
259
+ merge-multiple : true
260
+ - name : Cleanup
261
+ run : |
262
+ # Remove the granular manifests
263
+ rm -f artifacts/*-dist-manifest.json
264
+ - name : Create GitHub Release
265
+ env :
266
+ PRERELEASE_FLAG : " ${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
267
+ ANNOUNCEMENT_TITLE : " ${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
268
+ ANNOUNCEMENT_BODY : " ${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
269
+ RELEASE_COMMIT : " ${{ github.sha }}"
270
+ run : |
271
+ # Write and read notes from a file to avoid quoting breaking things
272
+ echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
273
+
274
+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
233
275
234
- # Create a GitHub Release while uploading all files to it
235
276
announce :
236
277
needs :
237
278
- plan
@@ -247,21 +288,3 @@ jobs:
247
288
- uses : actions/checkout@v4
248
289
with :
249
290
submodules : recursive
250
- - name : " Download GitHub Artifacts"
251
- uses : actions/download-artifact@v4
252
- with :
253
- pattern : artifacts-*
254
- path : artifacts
255
- merge-multiple : true
256
- - name : Cleanup
257
- run : |
258
- # Remove the granular manifests
259
- rm -f artifacts/*-dist-manifest.json
260
- - name : Create GitHub Release
261
- uses : ncipollo/release-action@v1
262
- with :
263
- tag : ${{ needs.plan.outputs.tag }}
264
- name : ${{ fromJson(needs.host.outputs.val).announcement_title }}
265
- body : ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
266
- prerelease : ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
267
- artifacts : " artifacts/*"
0 commit comments