1
- # Copyright 2022-2023, axodotdev
1
+ # This file was autogenerated by 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
- # * 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
- # * 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
- #
14
- # This file was generated by cargo dist init.
15
- # Some tips you could find here https://opensource.axo.dev/cargo-dist/book
16
15
17
16
name : Release
18
-
19
17
permissions :
20
- contents : write
18
+ " contents " : " write"
21
19
22
20
# This task will run whenever you push a git tag that looks like a version
23
21
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -26,29 +24,30 @@ permissions:
26
24
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
27
25
#
28
26
# If PACKAGE_NAME is specified, then the announcement will be for that
29
- # 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).
30
28
#
31
29
# If PACKAGE_NAME isn't specified, then the announcement will be for all
32
- # (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
33
31
# intended for workspaces with only one dist-able package, or with all dist-able
34
32
# packages versioned/released in lockstep).
35
33
#
36
34
# If you push multiple tags at once, separate instances of this workflow will
37
- # spin up, creating an independent announcement for each one. However Github
35
+ # spin up, creating an independent announcement for each one. However, GitHub
38
36
# will hard limit this to 3 tags per commit, as it will assume more tags is a
39
37
# mistake.
40
38
#
41
39
# If there's a prerelease-style suffix to the version, then the release(s)
42
40
# will be marked as a prerelease.
43
41
on :
42
+ # pull_request:
44
43
push :
45
44
tags :
46
45
- ' **[0-9]+.[0-9]+.[0-9]+*'
47
46
48
47
jobs :
49
- # 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
50
49
plan :
51
- runs-on : ubuntu-latest
50
+ runs-on : " ubuntu-20.04 "
52
51
outputs :
53
52
val : ${{ steps.plan.outputs.manifest }}
54
53
tag : ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -60,27 +59,34 @@ jobs:
60
59
- uses : actions/checkout@v4
61
60
with :
62
61
submodules : recursive
63
- - name : Install cargo-dist
62
+ - name : Update Rust
63
+ run : rustup update
64
+ - name : Install dist
64
65
# we specify bash to get pipefail; it guards against the `curl` command
65
66
# failing. otherwise `sh` won't catch that `curl` returned non-0
66
67
shell : bash
67
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.8.0/cargo-dist-installer.sh | sh"
68
+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.28.0/cargo-dist-installer.sh | sh"
69
+ - name : Cache dist
70
+ uses : actions/upload-artifact@v4
71
+ with :
72
+ name : cargo-dist-cache
73
+ path : ~/.cargo/bin/dist
68
74
# sure would be cool if github gave us proper conditionals...
69
75
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
70
76
# functionality based on whether this is a pull_request, and whether it's from a fork.
71
77
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
72
78
# but also really annoying to build CI around when it needs secrets to work right.)
73
79
- id : plan
74
80
run : |
75
- cargo dist ${{ !github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name) || (github.event.pull_request.head.repo.fork && 'plan' || 'host --steps=check') }} --output-format=json > dist-manifest.json
76
- echo "cargo dist ran successfully"
77
- cat dist-manifest.json
78
- echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
81
+ dist ${{ ( !github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan- dist-manifest.json
82
+ echo "dist ran successfully"
83
+ cat plan- dist-manifest.json
84
+ echo "manifest=$(jq -c "." plan- dist-manifest.json)" >> "$GITHUB_OUTPUT"
79
85
- name : " Upload dist-manifest.json"
80
- uses : actions/upload-artifact@v3
86
+ uses : actions/upload-artifact@v4
81
87
with :
82
- name : artifacts
83
- path : dist-manifest.json
88
+ name : artifacts-plan-dist-manifest
89
+ path : plan- dist-manifest.json
84
90
85
91
# Build and packages all the platform-specific things
86
92
build-local-artifacts :
@@ -91,42 +97,55 @@ jobs:
91
97
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') }}
92
98
strategy :
93
99
fail-fast : false
94
- # Target platforms/runners are computed by cargo- dist in create-release.
100
+ # Target platforms/runners are computed by dist in create-release.
95
101
# Each member of the matrix has the following arguments:
96
102
#
97
103
# - runner: the github runner
98
- # - dist-args: cli flags to pass to cargo dist
99
- # - install-dist: expression to run to install cargo- dist on the runner
104
+ # - dist-args: cli flags to pass to dist
105
+ # - install-dist: expression to run to install dist on the runner
100
106
#
101
107
# Typically there will be:
102
108
# - 1 "global" task that builds universal installers
103
109
# - N "local" tasks that build each platform's binaries and platform-specific installers
104
110
matrix : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
105
111
runs-on : ${{ matrix.runner }}
112
+ container : ${{ matrix.container && matrix.container.image || null }}
106
113
env :
107
114
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
108
115
BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
109
116
steps :
117
+ - name : enable windows longpaths
118
+ run : |
119
+ git config --global core.longpaths true
110
120
- uses : actions/checkout@v4
111
121
with :
112
122
submodules : recursive
113
- - uses : swatinem/rust-cache@v2
114
- - name : Install cargo-dist
115
- run : ${{ matrix.install_dist }}
123
+ - name : Install Rust non-interactively if not already installed
124
+ if : ${{ matrix.container }}
125
+ run : |
126
+ if ! command -v cargo > /dev/null 2>&1; then
127
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
128
+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
129
+ fi
130
+ - name : Update Rust
131
+ run : rustup update
132
+ - name : Install dist
133
+ run : ${{ matrix.install_dist.run }}
116
134
# Get the dist-manifest
117
135
- name : Fetch local artifacts
118
- uses : actions/download-artifact@v3
136
+ uses : actions/download-artifact@v4
119
137
with :
120
- name : artifacts
138
+ pattern : artifacts-*
121
139
path : target/distrib/
140
+ merge-multiple : true
122
141
- name : Install dependencies
123
142
run : |
124
143
${{ matrix.packages_install }}
125
144
- name : Build artifacts
126
145
run : |
127
146
# 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"
147
+ dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
148
+ echo "dist ran successfully"
130
149
- id : cargo-dist
131
150
name : Post-build
132
151
# We force bash here just because github makes it really hard to get values up
@@ -136,14 +155,14 @@ jobs:
136
155
run : |
137
156
# Parse out what we just built and upload it to scratch storage
138
157
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
139
- jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
158
+ dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
140
159
echo "EOF" >> "$GITHUB_OUTPUT"
141
160
142
161
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
143
162
- name : " Upload artifacts"
144
- uses : actions/upload-artifact@v3
163
+ uses : actions/upload-artifact@v4
145
164
with :
146
- name : artifacts
165
+ name : artifacts-build-local-${{ join(matrix.targets, '_') }}
147
166
path : |
148
167
${{ steps.cargo-dist.outputs.paths }}
149
168
${{ env.BUILD_MANIFEST_NAME }}
@@ -161,30 +180,37 @@ jobs:
161
180
- uses : actions/checkout@v4
162
181
with :
163
182
submodules : recursive
164
- - name : Install cargo-dist
165
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.8.0/cargo-dist-installer.sh | sh"
183
+ - name : Update Rust
184
+ run : rustup update
185
+ - name : Install cached dist
186
+ uses : actions/download-artifact@v4
187
+ with :
188
+ name : cargo-dist-cache
189
+ path : ~/.cargo/bin/
190
+ - run : chmod +x ~/.cargo/bin/dist
166
191
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
167
192
- name : Fetch local artifacts
168
- uses : actions/download-artifact@v3
193
+ uses : actions/download-artifact@v4
169
194
with :
170
- name : artifacts
195
+ pattern : artifacts-*
171
196
path : target/distrib/
197
+ merge-multiple : true
172
198
- id : cargo-dist
173
199
shell : bash
174
200
run : |
175
- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
176
- echo "cargo dist ran successfully"
201
+ dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
202
+ echo "dist ran successfully"
177
203
178
204
# Parse out what we just built and upload it to scratch storage
179
205
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
180
- jq --raw-output ".artifacts[]?.path | select( . != null ) " dist-manifest.json >> "$GITHUB_OUTPUT"
206
+ jq --raw-output ".upload_files[] " dist-manifest.json >> "$GITHUB_OUTPUT"
181
207
echo "EOF" >> "$GITHUB_OUTPUT"
182
208
183
209
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
184
210
- name : " Upload artifacts"
185
- uses : actions/upload-artifact@v3
211
+ uses : actions/upload-artifact@v4
186
212
with :
187
- name : artifacts
213
+ name : artifacts-build-global
188
214
path : |
189
215
${{ steps.cargo-dist.outputs.paths }}
190
216
${{ env.BUILD_MANIFEST_NAME }}
@@ -205,29 +231,57 @@ jobs:
205
231
- uses : actions/checkout@v4
206
232
with :
207
233
submodules : recursive
208
- - name : Install cargo-dist
209
- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.8.0/cargo-dist-installer.sh | sh"
234
+ - name : Update Rust
235
+ run : rustup update
236
+ - name : Install cached dist
237
+ uses : actions/download-artifact@v4
238
+ with :
239
+ name : cargo-dist-cache
240
+ path : ~/.cargo/bin/
241
+ - run : chmod +x ~/.cargo/bin/dist
210
242
# Fetch artifacts from scratch-storage
211
243
- name : Fetch artifacts
212
- uses : actions/download-artifact@v3
244
+ uses : actions/download-artifact@v4
213
245
with :
214
- name : artifacts
246
+ pattern : artifacts-*
215
247
path : target/distrib/
216
- # This is a harmless no-op for Github Releases, hosting for that happens in "announce"
248
+ merge-multiple : true
217
249
- id : host
218
250
shell : bash
219
251
run : |
220
- cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
252
+ dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
221
253
echo "artifacts uploaded and released successfully"
222
254
cat dist-manifest.json
223
255
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
224
256
- name : " Upload dist-manifest.json"
225
- uses : actions/upload-artifact@v3
257
+ uses : actions/upload-artifact@v4
226
258
with :
227
- name : artifacts
259
+ # Overwrite the previous copy
260
+ name : artifacts-dist-manifest
228
261
path : dist-manifest.json
262
+ # Create a GitHub Release while uploading all files to it
263
+ - name : " Download GitHub Artifacts"
264
+ uses : actions/download-artifact@v4
265
+ with :
266
+ pattern : artifacts-*
267
+ path : artifacts
268
+ merge-multiple : true
269
+ - name : Cleanup
270
+ run : |
271
+ # Remove the granular manifests
272
+ rm -f artifacts/*-dist-manifest.json
273
+ - name : Create GitHub Release
274
+ env :
275
+ PRERELEASE_FLAG : " ${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
276
+ ANNOUNCEMENT_TITLE : " ${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
277
+ ANNOUNCEMENT_BODY : " ${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
278
+ RELEASE_COMMIT : " ${{ github.sha }}"
279
+ run : |
280
+ # Write and read notes from a file to avoid quoting breaking things
281
+ echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
282
+
283
+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/casr-*
229
284
230
- # Create a Github Release while uploading all files to it
231
285
announce :
232
286
needs :
233
287
- plan
@@ -243,21 +297,3 @@ jobs:
243
297
- uses : actions/checkout@v4
244
298
with :
245
299
submodules : recursive
246
- - name : " Download Github Artifacts"
247
- uses : actions/download-artifact@v3
248
- with :
249
- name : artifacts
250
- path : artifacts
251
- - name : Cleanup
252
- run : |
253
- # Remove the granular manifests
254
- rm -f artifacts/*-dist-manifest.json
255
- - name : Create Github Release
256
- uses : ncipollo/release-action@v1
257
- with :
258
- tag : ${{ needs.plan.outputs.tag }}
259
- name : ${{ fromJson(needs.host.outputs.val).announcement_title }}
260
- body : ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
261
- prerelease : ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
262
- # Upload only binary release and checksum for it.
263
- artifacts : " artifacts/casr-x86_64-unknown-linux-gnu.tar.xz*"
0 commit comments