-
Notifications
You must be signed in to change notification settings - Fork 0
371 lines (341 loc) · 13 KB
/
Copy pathrelease.yml
File metadata and controls
371 lines (341 loc) · 13 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
name: Release
on:
workflow_call:
inputs:
ref:
description: Git revision containing the release packages
required: true
type: string
tag:
description: GitHub Release tag created by release-please
required: true
type: string
commit:
description: Release commit used for version identity
required: true
type: string
secrets:
GH_TOKEN:
description: Dedicated cross-repository token with write access to wrightkit/homebrew-tap
required: true
permissions:
contents: write
jobs:
release-gates:
name: Release gates
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ inputs.tag }}
RELEASE_COMMIT: ${{ inputs.commit }}
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
ref: ${{ env.RELEASE_TAG }}
fetch-depth: 0
- name: Verify release revision and tag identity
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ inputs.tag }}
RELEASE_COMMIT: ${{ inputs.commit }}
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "${RELEASE_COMMIT}"
tag_commit="$(gh api \
"repos/${GITHUB_REPOSITORY}/commits/${RELEASE_TAG}" \
--jq .sha)"
test "${tag_commit}" = "${RELEASE_COMMIT}"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rustfmt
- name: Verify tag version matches the workspace implementation version
run: |
set -euo pipefail
VERSION="${RELEASE_TAG#v}"
PACKAGE_VERSION="$(cargo metadata --locked --no-deps --format-version 1 | \
python3 -c 'import json, sys; print(next(p["version"] for p in json.load(sys.stdin)["packages"] if p["name"] == "wright-cli"))')"
if [[ "$VERSION" != "$PACKAGE_VERSION" ]]; then
echo "tag $RELEASE_TAG does not match the workspace implementation version $PACKAGE_VERSION"
exit 1
fi
echo "workspace version $PACKAGE_VERSION matches tag $RELEASE_TAG"
- name: Run release gates (fmt, clippy, tests, v1 gates, scenarios, benchmarks, standalone proof)
run: scripts/release.sh "${RELEASE_TAG#v}"
- name: Verify checked-in distribution metadata
run: python3 scripts/verify-dist.py
- name: Upload gate reports
if: always()
uses: actions/upload-artifact@v7
with:
name: release-gate-reports
path: |
target/v1-gates-report.json
target/scenarios-report.json
target/wright-bench-report.json
build:
name: Build ${{ matrix.target }}
needs: release-gates
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
ext: tar.gz
- os: macos-15-intel
target: x86_64-apple-darwin
ext: tar.gz
- os: macos-15
target: aarch64-apple-darwin
ext: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
ext: zip
defaults:
run:
shell: bash
env:
RELEASE_TAG: ${{ inputs.tag }}
TARGET: ${{ matrix.target }}
EXT: ${{ matrix.ext }}
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Add cross-compile target
run: rustup target add "$TARGET"
- name: Build release binaries
run: cargo build --locked --release -p wright-cli -p wright-lsp --target "$TARGET"
- name: Package archive with version stamp
run: |
set -euo pipefail
VERSION="${RELEASE_TAG#v}"
PAYLOAD="wright-$VERSION-$TARGET"
mkdir -p "dist/$PAYLOAD"
scripts/make-version-stamp.sh "$VERSION" "dist/$PAYLOAD/version.json"
if [[ "$RUNNER_OS" == "Windows" ]]; then EXE=".exe"; else EXE=""; fi
cp "target/$TARGET/release/wright$EXE" "dist/$PAYLOAD/"
cp "target/$TARGET/release/wright-lsp$EXE" "dist/$PAYLOAD/"
if [[ "$EXT" == "zip" ]]; then
(cd dist && pwsh -NoLogo -NoProfile -NonInteractive -Command \
"Compress-Archive -Path '$PAYLOAD' -DestinationPath '$PAYLOAD.zip' -Force")
else
(cd dist && tar -czf "$PAYLOAD.tar.gz" "$PAYLOAD")
fi
if command -v sha256sum >/dev/null 2>&1; then
(cd dist && sha256sum "$PAYLOAD.$EXT" > "$PAYLOAD.$EXT.sha256")
else
(cd dist && shasum -a 256 "$PAYLOAD.$EXT" > "$PAYLOAD.$EXT.sha256")
fi
ls -l dist/
- name: Smoke test the packaged archive
run: |
set -euo pipefail
VERSION="${RELEASE_TAG#v}"
PAYLOAD="wright-$VERSION-$TARGET"
if [[ "$EXT" == "zip" ]]; then
EXTRACT="dist/smoke-extract"
pwsh -NoLogo -NoProfile -NonInteractive -Command \
"Expand-Archive -LiteralPath 'dist/$PAYLOAD.$EXT' -DestinationPath '$EXTRACT' -Force"
else
EXTRACT="$(mktemp -d)"
tar -xf "dist/$PAYLOAD.$EXT" -C "$EXTRACT"
fi
if [[ "$RUNNER_OS" == "Windows" ]]; then EXE=".exe"; else EXE=""; fi
WRIGHT="$EXTRACT/$PAYLOAD/wright$EXE"
LSP="$EXTRACT/$PAYLOAD/wright-lsp$EXE"
test -f "$WRIGHT" || { echo "missing $WRIGHT"; exit 1; }
test -f "$LSP" || { echo "missing $LSP"; exit 1; }
python scripts/smoke-native.py \
--wright "$WRIGHT" \
--wright-lsp "$LSP" \
--version "$VERSION" \
--provider-bootstrap
- name: Upload release artifacts
uses: actions/upload-artifact@v7
with:
name: wright-${{ matrix.target }}
path: |
dist/wright-*.tar.gz
dist/wright-*.tar.gz.sha256
dist/wright-*.zip
dist/wright-*.zip.sha256
upload-artifacts:
name: Upload native release artifacts
needs: build
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ inputs.tag }}
steps:
- name: Download release artifacts
uses: actions/download-artifact@v8
with:
pattern: wright-*
path: artifacts
- name: Verify the complete artifact set
run: |
set -euo pipefail
VERSION="${RELEASE_TAG#v}"
mkdir -p release
for triple in x86_64-unknown-linux-gnu x86_64-apple-darwin aarch64-apple-darwin x86_64-pc-windows-msvc; do
ext="tar.gz"
[[ "$triple" == "x86_64-pc-windows-msvc" ]] && ext="zip"
archive="wright-$VERSION-$triple.$ext"
test -f "artifacts/wright-$triple/$archive" || { echo "missing $archive"; exit 1; }
test -f "artifacts/wright-$triple/$archive.sha256" || { echo "missing $archive.sha256"; exit 1; }
cp "artifacts/wright-$triple/$archive" "release/"
cp "artifacts/wright-$triple/$archive.sha256" "release/"
done
(cd release && sha256sum wright-*.tar.gz wright-*.zip > SHA256SUMS)
ls -l release/
- name: Verify the release-please draft Release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
release="$(gh release view "${RELEASE_TAG}" \
--repo "${GITHUB_REPOSITORY}" \
--json tagName,isDraft,isImmutable,url)"
echo "${release}"
test "$(jq -r .tagName <<<"${release}")" = "${RELEASE_TAG}"
test "$(jq -r .isDraft <<<"${release}")" = "true"
- name: Attach native archives and checksums
env:
GH_TOKEN: ${{ github.token }}
run: >-
gh release upload "${RELEASE_TAG}" release/* --clobber
--repo "${GITHUB_REPOSITORY}"
package-manifests:
name: Generate package-manager manifests
needs: upload-artifacts
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ inputs.tag }}
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
- name: Download release artifacts
uses: actions/download-artifact@v8
with:
pattern: wright-*
path: artifacts
- name: Generate manifests from the published checksums
run: |
set -euo pipefail
VERSION="${RELEASE_TAG#v}"
for triple in x86_64-unknown-linux-gnu aarch64-apple-darwin x86_64-apple-darwin x86_64-pc-windows-msvc; do
ext="tar.gz"
[[ "$triple" == "x86_64-pc-windows-msvc" ]] && ext="zip"
sha256_file="artifacts/wright-$triple/wright-$VERSION-$triple.$ext.sha256"
test -f "$sha256_file" || { echo "missing $sha256_file"; exit 1; }
hash="$(awk 'NR == 1 { print $1 }' "$sha256_file")"
[[ "$hash" =~ ^[0-9a-f]{64}$ ]] || { echo "invalid hash in $sha256_file"; exit 1; }
case "$triple" in
x86_64-unknown-linux-gnu) linux_x64_hash="$hash" ;;
aarch64-apple-darwin) darwin_arm64_hash="$hash" ;;
x86_64-apple-darwin) darwin_x64_hash="$hash" ;;
x86_64-pc-windows-msvc) windows_x64_hash="$hash" ;;
esac
echo "$triple: $hash"
done
python3 scripts/update-dist-manifests.py \
--version "$VERSION" \
--linux-x64-hash "$linux_x64_hash" \
--darwin-arm64-hash "$darwin_arm64_hash" \
--darwin-x64-hash "$darwin_x64_hash" \
--windows-x64-hash "$windows_x64_hash" \
--out-dir "$GITHUB_WORKSPACE/manifests"
mkdir -p "$GITHUB_WORKSPACE/attach"
cp "$GITHUB_WORKSPACE/manifests/dist/homebrew/wright.rb" \
"$GITHUB_WORKSPACE/attach/wright-$VERSION.homebrew.rb"
cp "$GITHUB_WORKSPACE/manifests/dist/scoop/wright.json" \
"$GITHUB_WORKSPACE/attach/wright-$VERSION.scoop.json"
(cd "$GITHUB_WORKSPACE/manifests/dist/winget" && tar -a -cf "$GITHUB_WORKSPACE/attach/wright-$VERSION.winget.zip" manifests)
ls -l "$GITHUB_WORKSPACE/attach"
- name: Upload Homebrew formula for tap publication
uses: actions/upload-artifact@v7
with:
name: homebrew-formula
path: ${{ github.workspace }}/manifests/dist/homebrew/wright.rb
if-no-files-found: error
- name: Attach package-manager manifests to the draft Release
env:
GH_TOKEN: ${{ github.token }}
run: >-
gh release upload "${RELEASE_TAG}" attach/* --clobber
--repo "${GITHUB_REPOSITORY}"
publish-tap:
name: Publish formula to homebrew-tap
needs:
- package-manifests
- publish-release
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ inputs.tag }}
steps:
- name: Download generated Homebrew formula
uses: actions/download-artifact@v8
with:
name: homebrew-formula
path: formula
- name: Check out wrightkit/homebrew-tap
uses: actions/checkout@v7
with:
repository: wrightkit/homebrew-tap
ref: main
# Only this cross-repository tap operation uses secrets.GH_TOKEN.
token: ${{ secrets.GH_TOKEN }}
path: tap
- name: Update wright.rb and push to the tap
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
set -euo pipefail
VERSION="${RELEASE_TAG#v}"
if [[ -z "${GH_TOKEN}" ]]; then
echo "error: GH_TOKEN secret is not set." >&2
echo "Add a fine-grained PAT with Contents: Read and write on" >&2
echo "wrightkit/homebrew-tap as an Actions secret available to this repository." >&2
exit 1
fi
cp formula/wright.rb tap/wright.rb
cd tap
if git diff --quiet -- wright.rb; then
echo "wright.rb is already current for ${RELEASE_TAG}; nothing to push"
exit 0
fi
git -c user.name="wrightkit-bot" \
-c user.email="wrightkit-bot@users.noreply.github.com" \
commit -m "Update wright formula to ${VERSION}" -- wright.rb
git push origin HEAD
echo "pushed wright.rb for ${RELEASE_TAG} to wrightkit/homebrew-tap"
publish-release:
name: Publish completed GitHub Release
needs:
- package-manifests
runs-on: ubuntu-latest
environment: release
steps:
- name: Publish the completed draft Release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ inputs.tag }}
run: >-
gh release edit "${RELEASE_TAG}" --draft=false --latest
--repo "${GITHUB_REPOSITORY}"