Skip to content

Commit 41f6a5f

Browse files
committed
Fix: Update workflow.
1 parent 66905f4 commit 41f6a5f

File tree

2 files changed

+52
-333
lines changed

2 files changed

+52
-333
lines changed

.github/workflows/release.yml

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# This file was autogenerated by dist: https://opensource.axo.dev/cargo-dist/
2+
#
13
# Copyright 2022-2024, axodotdev
24
# SPDX-License-Identifier: MIT or Apache-2.0
35
#
46
# CI that:
57
#
68
# * 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)
810
# * uploads those artifacts to temporary workflow zip
911
# * on success, uploads the artifacts to a GitHub Release
1012
#
@@ -22,10 +24,10 @@ permissions:
2224
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
2325
#
2426
# If PACKAGE_NAME is specified, then the announcement will be for that
25-
# 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).
2628
#
2729
# If PACKAGE_NAME isn't specified, then the announcement will be for all
28-
# (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
2931
# intended for workspaces with only one dist-able package, or with all dist-able
3032
# packages versioned/released in lockstep).
3133
#
@@ -43,7 +45,7 @@ on:
4345
- '**[0-9]+.[0-9]+.[0-9]+*'
4446

4547
jobs:
46-
# 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
4749
plan:
4850
runs-on: "ubuntu-20.04"
4951
outputs:
@@ -57,16 +59,16 @@ jobs:
5759
- uses: actions/checkout@v4
5860
with:
5961
submodules: recursive
60-
- name: Install cargo-dist
62+
- name: Install dist
6163
# we specify bash to get pipefail; it guards against the `curl` command
6264
# failing. otherwise `sh` won't catch that `curl` returned non-0
6365
shell: bash
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+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.26.1/cargo-dist-installer.sh | sh"
67+
- name: Cache dist
6668
uses: actions/upload-artifact@v4
6769
with:
6870
name: cargo-dist-cache
69-
path: ~/.cargo/bin/cargo-dist
71+
path: ~/.cargo/bin/dist
7072
# sure would be cool if github gave us proper conditionals...
7173
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
7274
# functionality based on whether this is a pull_request, and whether it's from a fork.
@@ -75,37 +77,43 @@ jobs:
7577
- id: plan
7678
run: |
7779
cd server
78-
cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
79-
echo "cargo dist ran successfully"
80+
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
81+
echo "dist ran successfully"
8082
cat plan-dist-manifest.json
8183
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
8284
- name: "Upload dist-manifest.json"
8385
uses: actions/upload-artifact@v4
8486
with:
8587
name: artifacts-plan-dist-manifest
86-
path: server/plan-dist-manifest.json
88+
path: plan-dist-manifest.json
89+
90+
custom-plan:
91+
uses: ./.github/workflows/plan.yml
92+
secrets: inherit
8793

8894
# Build and packages all the platform-specific things
8995
build-local-artifacts:
9096
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
9197
# Let the initial task tell us to not run (currently very blunt)
9298
needs:
9399
- plan
100+
- custom-plan
94101
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') }}
95102
strategy:
96103
fail-fast: false
97-
# Target platforms/runners are computed by cargo-dist in create-release.
104+
# Target platforms/runners are computed by dist in create-release.
98105
# Each member of the matrix has the following arguments:
99106
#
100107
# - runner: the github runner
101-
# - dist-args: cli flags to pass to cargo dist
102-
# - install-dist: expression to run to install cargo-dist on the runner
108+
# - dist-args: cli flags to pass to dist
109+
# - install-dist: expression to run to install dist on the runner
103110
#
104111
# Typically there will be:
105112
# - 1 "global" task that builds universal installers
106113
# - N "local" tasks that build each platform's binaries and platform-specific installers
107114
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
108115
runs-on: ${{ matrix.runner }}
116+
container: ${{ matrix.container && matrix.container.image || null }}
109117
env:
110118
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111119
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
@@ -116,14 +124,25 @@ jobs:
116124
- uses: actions/checkout@v4
117125
with:
118126
submodules: recursive
119-
- name: Install cargo-dist
120-
run: ${{ matrix.install_dist }}
127+
- name: Install Rust non-interactively if not already installed
128+
if: ${{ matrix.container }}
129+
run: |
130+
if ! command -v cargo > /dev/null 2>&1; then
131+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
132+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
133+
fi
134+
- uses: swatinem/rust-cache@v2
135+
with:
136+
key: ${{ join(matrix.targets, '-') }}
137+
cache-provider: ${{ matrix.cache_provider }}
138+
- name: Install dist
139+
run: ${{ matrix.install_dist.run }}
121140
# Get the dist-manifest
122141
- name: Fetch local artifacts
123142
uses: actions/download-artifact@v4
124143
with:
125144
pattern: artifacts-*
126-
path: server/target/distrib/
145+
path: target/distrib/
127146
merge-multiple: true
128147
- name: Install dependencies
129148
run: |
@@ -132,8 +151,8 @@ jobs:
132151
run: |
133152
cd server
134153
# Actually do builds and make zips and whatnot
135-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
136-
echo "cargo dist ran successfully"
154+
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
155+
echo "dist ran successfully"
137156
- id: cargo-dist
138157
name: Post-build
139158
# We force bash here just because github makes it really hard to get values up
@@ -144,7 +163,7 @@ jobs:
144163
cd server
145164
# Parse out what we just built and upload it to scratch storage
146165
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
147-
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
166+
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
148167
echo "EOF" >> "$GITHUB_OUTPUT"
149168
150169
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -169,12 +188,12 @@ jobs:
169188
- uses: actions/checkout@v4
170189
with:
171190
submodules: recursive
172-
- name: Install cached cargo-dist
191+
- name: Install cached dist
173192
uses: actions/download-artifact@v4
174193
with:
175194
name: cargo-dist-cache
176195
path: ~/.cargo/bin/
177-
- run: chmod +x ~/.cargo/bin/cargo-dist
196+
- run: chmod +x ~/.cargo/bin/dist
178197
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
179198
- name: Fetch local artifacts
180199
uses: actions/download-artifact@v4
@@ -186,8 +205,8 @@ jobs:
186205
shell: bash
187206
run: |
188207
cd server
189-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
190-
echo "cargo dist ran successfully"
208+
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
209+
echo "dist ran successfully"
191210
192211
# Parse out what we just built and upload it to scratch storage
193212
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -219,12 +238,12 @@ jobs:
219238
- uses: actions/checkout@v4
220239
with:
221240
submodules: recursive
222-
- name: Install cached cargo-dist
241+
- name: Install cached dist
223242
uses: actions/download-artifact@v4
224243
with:
225244
name: cargo-dist-cache
226245
path: ~/.cargo/bin/
227-
- run: chmod +x ~/.cargo/bin/cargo-dist
246+
- run: chmod +x ~/.cargo/bin/dist
228247
# Fetch artifacts from scratch-storage
229248
- name: Fetch artifacts
230249
uses: actions/download-artifact@v4
@@ -236,7 +255,7 @@ jobs:
236255
shell: bash
237256
run: |
238257
cd server
239-
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
258+
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
240259
echo "artifacts uploaded and released successfully"
241260
cat dist-manifest.json
242261
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -269,29 +288,25 @@ jobs:
269288
270289
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
271290
272-
custom-npm-build:
291+
custom-host:
273292
needs:
274293
- plan
275-
- host
276-
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
277-
uses: ./.github/workflows/npm-build.yml
294+
- build-local-artifacts
295+
- build-global-artifacts
296+
uses: ./.github/workflows/host.yml
278297
with:
279298
plan: ${{ needs.plan.outputs.val }}
280299
secrets: inherit
281-
# publish jobs get escalated permissions
282-
permissions:
283-
"id-token": "write"
284-
"packages": "write"
285300

286301
announce:
287302
needs:
288303
- plan
289304
- host
290-
- custom-npm-build
305+
- custom-host
291306
# use "always() && ..." to allow us to wait for all publish jobs while
292307
# still allowing individual publish jobs to skip themselves (for prereleases).
293308
# "host" however must run to completion, no skipping allowed!
294-
if: ${{ always() && needs.host.result == 'success' && (needs.custom-npm-build.result == 'skipped' || needs.custom-npm-build.result == 'success') }}
309+
if: ${{ always() && needs.host.result == 'success' }}
295310
runs-on: "ubuntu-20.04"
296311
env:
297312
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)