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
#
@@ -38,15 +39,15 @@ permissions:
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.13.1/cargo-dist-installer.sh | sh"
66
+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.28.0/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,30 +95,38 @@ 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
101
107
# - N "local" tasks that build each platform's binaries and platform-specific installers
102
108
matrix : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
103
109
runs-on : ${{ matrix.runner }}
110
+ container : ${{ matrix.container && matrix.container.image || null }}
104
111
env :
105
112
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
106
113
BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
107
114
steps :
115
+ - name : enable windows longpaths
116
+ run : |
117
+ git config --global core.longpaths true
108
118
- uses : actions/checkout@v4
109
119
with :
110
120
submodules : recursive
111
- - uses : swatinem/rust-cache@v2
112
- with :
113
- key : ${{ join(matrix.targets, '-') }}
114
- - name : Install cargo-dist
115
- run : ${{ matrix.install_dist }}
121
+ - name : Install Rust non-interactively if not already installed
122
+ if : ${{ matrix.container }}
123
+ run : |
124
+ if ! command -v cargo > /dev/null 2>&1; then
125
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
126
+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
127
+ fi
128
+ - name : Install dist
129
+ run : ${{ matrix.install_dist.run }}
116
130
# Get the dist-manifest
117
131
- name : Fetch local artifacts
118
132
uses : actions/download-artifact@v4
@@ -126,8 +140,8 @@ jobs:
126
140
- name : Build artifacts
127
141
run : |
128
142
# Actually do builds and make zips and whatnot
129
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
130
- echo "cargo dist ran successfully"
143
+ dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
144
+ echo "dist ran successfully"
131
145
- id : cargo-dist
132
146
name : Post-build
133
147
# We force bash here just because github makes it really hard to get values up
@@ -137,7 +151,7 @@ jobs:
137
151
run : |
138
152
# Parse out what we just built and upload it to scratch storage
139
153
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
140
- jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
154
+ dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
141
155
echo "EOF" >> "$GITHUB_OUTPUT"
142
156
143
157
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -162,9 +176,12 @@ jobs:
162
176
- uses : actions/checkout@v4
163
177
with :
164
178
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.1/cargo-dist-installer.sh | sh"
179
+ - name : Install cached dist
180
+ uses : actions/download-artifact@v4
181
+ with :
182
+ name : cargo-dist-cache
183
+ path : ~/.cargo/bin/
184
+ - run : chmod +x ~/.cargo/bin/dist
168
185
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
169
186
- name : Fetch local artifacts
170
187
uses : actions/download-artifact@v4
@@ -175,8 +192,8 @@ jobs:
175
192
- id : cargo-dist
176
193
shell : bash
177
194
run : |
178
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
179
- echo "cargo dist ran successfully"
195
+ dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
196
+ echo "dist ran successfully"
180
197
181
198
# Parse out what we just built and upload it to scratch storage
182
199
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -208,20 +225,23 @@ jobs:
208
225
- uses : actions/checkout@v4
209
226
with :
210
227
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.1/cargo-dist-installer.sh | sh"
228
+ - name : Install cached dist
229
+ uses : actions/download-artifact@v4
230
+ with :
231
+ name : cargo-dist-cache
232
+ path : ~/.cargo/bin/
233
+ - run : chmod +x ~/.cargo/bin/dist
213
234
# Fetch artifacts from scratch-storage
214
235
- name : Fetch artifacts
215
236
uses : actions/download-artifact@v4
216
237
with :
217
238
pattern : artifacts-*
218
239
path : target/distrib/
219
240
merge-multiple : true
220
- # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
221
241
- id : host
222
242
shell : bash
223
243
run : |
224
- cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
244
+ dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
225
245
echo "artifacts uploaded and released successfully"
226
246
cat dist-manifest.json
227
247
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -231,8 +251,29 @@ jobs:
231
251
# Overwrite the previous copy
232
252
name : artifacts-dist-manifest
233
253
path : dist-manifest.json
254
+ # Create a GitHub Release while uploading all files to it
255
+ - name : " Download GitHub Artifacts"
256
+ uses : actions/download-artifact@v4
257
+ with :
258
+ pattern : artifacts-*
259
+ path : artifacts
260
+ merge-multiple : true
261
+ - name : Cleanup
262
+ run : |
263
+ # Remove the granular manifests
264
+ rm -f artifacts/*-dist-manifest.json
265
+ - name : Create GitHub Release
266
+ env :
267
+ PRERELEASE_FLAG : " ${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
268
+ ANNOUNCEMENT_TITLE : " ${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
269
+ ANNOUNCEMENT_BODY : " ${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
270
+ RELEASE_COMMIT : " ${{ github.sha }}"
271
+ run : |
272
+ # Write and read notes from a file to avoid quoting breaking things
273
+ echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
274
+
275
+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
234
276
235
- # Create a GitHub Release while uploading all files to it
236
277
announce :
237
278
needs :
238
279
- plan
@@ -248,21 +289,3 @@ jobs:
248
289
- uses : actions/checkout@v4
249
290
with :
250
291
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