Repository navigation
241 lines (227 loc) · 9.04 KB
/
Copy pathrelease.yml
File metadata and controls
241 lines (227 loc) · 9.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: Release
on:
workflow_dispatch:
permissions:
contents: write
actions: write
id-token: write
attestations: write
concurrency:
group: release
cancel-in-progress: false
jobs:
macos:
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
uses: ./.github/workflows/macos.yml
permissions:
contents: read
attestations: read
with:
release-archive: true
check-installation: false
build:
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
uses: ./.github/workflows/linux-release.yml
permissions:
contents: read
with:
tag: ${{ github.ref_name }}
windows:
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
uses: ./.github/workflows/windows.yml
permissions:
contents: read
attestations: read
with:
release-archive: true
check-installation: false
draft:
needs: [build, macos, windows]
runs-on: ubuntu-26.04
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: linux-release
path: assets
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: macos-archive
path: macos
- name: Stage the frozen macOS archive
env:
EXPECTED_SHA256: ${{ needs.macos.outputs.archive-sha256 }}
run: |
test -n "$EXPECTED_SHA256"
digest=$(sha256sum macos/*.tar.gz)
test "${digest%% *}" = "$EXPECTED_SHA256"
(cd macos && sha256sum -c ./*.tar.gz.sha256)
cp macos/*.tar.gz macos/*.tar.gz.sha256 assets/
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: windows-archive
path: windows
- name: Stage the frozen Windows archive
env:
EXPECTED_SHA256: ${{ needs.windows.outputs.archive-sha256 }}
run: |
test -n "$EXPECTED_SHA256"
digest=$(sha256sum windows/*.tar.gz)
test "${digest%% *}" = "$EXPECTED_SHA256"
(cd windows && sha256sum -c ./*.tar.gz.sha256)
cp windows/*.tar.gz windows/*.tar.gz.sha256 assets/
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: |
assets/fastmash-*.tar.gz
assets/fastmash_*.deb
assets/fastmash-*.rpm
- name: Create the draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json isDraft > "$RUNNER_TEMP/release-state.json"; then
jq -e .isDraft "$RUNNER_TEMP/release-state.json" > /dev/null
gh release edit "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --notes-file assets/notes.md
else
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --verify-tag \
--title "Fastmash ${GITHUB_REF_NAME#v}" --notes-file assets/notes.md --draft
fi
existing=$(gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name')
mkdir "$RUNNER_TEMP/existing-assets"
for asset in assets/fastmash-*.tar.gz assets/fastmash_*.deb assets/fastmash-*.rpm assets/fastmash-*.sha256 assets/fastmash_*.sha256; do
name=$(basename "$asset")
if grep -qxF "$name" <<< "$existing"; then
gh release download "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --pattern "$name" --dir "$RUNNER_TEMP/existing-assets"
cmp "$asset" "$RUNNER_TEMP/existing-assets/$name"
else
gh release upload "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" "$asset"
fi
done
delivered-macos:
needs: [draft, macos]
uses: ./.github/workflows/macos-install.yml
permissions:
contents: write
attestations: read
with:
source: release
tag: ${{ github.ref_name }}
release-archive: true
archive-sha256: ${{ needs.macos.outputs.archive-sha256 }}
delivered-windows:
needs: [draft, windows]
uses: ./.github/workflows/windows-install.yml
permissions:
contents: write
attestations: read
with:
source: release
tag: ${{ github.ref_name }}
archive-sha256: ${{ needs.windows.outputs.archive-sha256 }}
publish:
needs: [draft, delivered-macos, delivered-windows, crates-check]
runs-on: ubuntu-26.04
timeout-minutes: 60
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: linux-release
path: expected
- name: Verify delivered Linux assets before publishing
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
mkdir "$RUNNER_TEMP/delivered"
gh release download "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --dir "$RUNNER_TEMP/delivered"
cd "$RUNNER_TEMP/delivered"
sha256sum -c ./*.sha256
# Installation tested these bytes before upload. Compare the downloads
# with the checksums retained by that build, then verify provenance.
for checksum in "$GITHUB_WORKSPACE"/expected/*.sha256; do
sha256sum -c "$checksum"
done
for asset in *.tar.gz *.deb *.rpm; do
gh attestation verify "$asset" --repo "$GITHUB_REPOSITORY" --signer-workflow "$GITHUB_REPOSITORY/.github/workflows/release.yml"
done
- name: Publish verified release and start package repository update
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
latest=$(gh api "repos/$GITHUB_REPOSITORY/releases/latest" --jq .tag_name)
test "$(printf '%s\n' "$latest" "$GITHUB_REF_NAME" | sort -V | tail -1)" = "$GITHUB_REF_NAME" ||
{ echo 'A newer version is already published.' >&2; exit 1; }
gh release edit "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft=false --latest
previous_run=$(gh run list --workflow package-repository.yml --branch "$GITHUB_REF_NAME" --json databaseId --limit 1 --jq '.[0].databaseId // 0')
gh workflow run package-repository.yml --ref "$GITHUB_REF_NAME" -f tag="$GITHUB_REF_NAME"
run=
for _ in {1..15}; do
run=$(gh run list --workflow package-repository.yml --branch "$GITHUB_REF_NAME" --commit "$GITHUB_SHA" --json databaseId --limit 1 --jq ".[0].databaseId | select(. > $previous_run)")
[ -z "$run" ] || break
sleep 2
done
test -n "$run" || { echo 'Package repository dispatch did not produce a run.' >&2; exit 1; }
gh run watch "$run" --exit-status
crates-check:
needs: draft
runs-on: ubuntu-26.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8
with:
toolchain: stable
- name: Check packaged sources before registry authentication
run: bash release/check-crate-packages.sh "${GITHUB_REF_NAME#v}"
crates-publish:
needs: publish
runs-on: ubuntu-26.04
environment: crates-io
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8
with:
toolchain: stable
- name: Obtain a temporary crates.io token
id: auth
uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1.0.6
- name: Publish the product package if missing
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: bash release/publish-crates.sh "${GITHUB_REF_NAME#v}" publish
binstall:
needs: crates-publish
uses: ./.github/workflows/cargo-binstall.yml
permissions:
contents: read
attestations: read
with:
version: ${{ github.ref_name }}
finish:
needs: [publish, crates-publish, binstall]
runs-on: ubuntu-26.04
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Advance the published website source and request its refresh
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
latest=$(gh api "repos/$GITHUB_REPOSITORY/releases/latest" --jq .tag_name)
test "$latest" = "$GITHUB_REF_NAME" || exit 0
old=$(git ls-remote --heads origin refs/heads/release | cut -f1)
git push --force-with-lease="refs/heads/release:$old" origin "$GITHUB_SHA:refs/heads/release"
gh workflow run website-deploy.yml --repo "$GITHUB_REPOSITORY" --ref main \
-f release_sha="$GITHUB_SHA"