Repository navigation
369 lines (358 loc) · 14.1 KB
/
Copy pathrelease.yml
File metadata and controls
369 lines (358 loc) · 14.1 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
name: Release
on:
push:
branches: [main]
workflow_dispatch:
inputs:
publish:
description: Publish the current main version, or resume its incomplete release
type: boolean
default: false
# The generated tag does not trigger another workflow: this run publishes it.
concurrency:
group: benchset-release
cancel-in-progress: false
permissions:
contents: read
jobs:
plan:
runs-on: ubuntu-24.04
outputs:
build: ${{ steps.plan.outputs.build }}
publish: ${{ steps.plan.outputs.publish }}
version: ${{ steps.plan.outputs.version }}
tag: ${{ steps.plan.outputs.tag }}
source_sha: ${{ steps.plan.outputs.source_sha }}
artifact_run_id: ${{ steps.plan.outputs.artifact_run_id }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Decide whether to build, resume, or skip this version
id: plan
env:
GH_TOKEN: ${{ github.token }}
RELEASE_PUBLISH: ${{ github.event_name == 'push' || inputs.publish }}
shell: bash
run: |
if [ "$RELEASE_PUBLISH" = "true" ]; then
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
echo "Publication must run from main" >&2
exit 1
fi
python scripts/release.py plan --publish
else
python scripts/release.py plan
fi
checks:
needs: plan
if: needs.plan.outputs.build == 'true'
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.plan.outputs.source_sha }}
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: dtolnay/rust-toolchain@1.94.1
- uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Keep Cargo on the MSVC linker when running in Git Bash
if: runner.os == 'Windows'
shell: pwsh
run: |
$msvcLink = Join-Path $env:VCToolsInstallDir 'bin\Hostx64\x64\link.exe'
if (!(Test-Path $msvcLink)) { throw "MSVC linker not found: $msvcLink" }
"CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=$msvcLink" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install both architectures for universal Apple package tests
if: runner.os == 'macOS'
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
- run: python -m pip install pytest==8.3.5 mypy==1.14.1 filelock==3.16.1 build==1.2.2.post1 wheel 'setuptools>=68' 'skelet>=0.0.21'
- run: python -m pip install .
- run: python scripts/build_native.py
- run: python -m pytest -q
wheels:
needs: plan
if: needs.plan.outputs.build == 'true'
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
arch: x86_64
- os: ubuntu-24.04-arm
arch: aarch64
- os: macos-15
arch: arm64
minimum: '11.0'
- os: macos-15-intel
arch: x86_64
minimum: '10.12'
- os: windows-latest
arch: AMD64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.plan.outputs.source_sha }}
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: dtolnay/rust-toolchain@1.94.1
- run: python -m pip install cibuildwheel==2.23.3
- name: Build and install interpreter-independent wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: 'cp311-*'
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: '*-musllinux*'
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: 'curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.94.1'
CIBW_ENVIRONMENT_LINUX: 'CARGO_HOME=/tmp/benchset-cargo RUSTUP_HOME=/tmp/benchset-rustup PATH=/tmp/benchset-cargo/bin:$PATH'
CIBW_ENVIRONMENT_MACOS: 'MACOSX_DEPLOYMENT_TARGET=${{ matrix.minimum }}'
CIBW_TEST_COMMAND: >-
python -c "import math; from benchset import PI_REFERENCE_MACHINE as m, PI_REFERENCE_RUN as p, run;
assert m.short_name == 'pi' and m.memory_bytes == 8589934592 and m.cpu_cores == 4;
assert p.warmup_seconds == 1248.0 and p.started_at_unix_seconds == 1792767590.517391;
refs = {r.benchmark: r.score for r in p.results};
assert refs == {'single_core': 47231.227029007096, 'multi_core': 181953.17419139884};
results = [run(name, warmup_seconds=0, measurement_seconds=0.05) for name in refs];
assert all(r.reference_machine is m and r.reference_run is p and
((r.success and math.isfinite(r.pi_equivalent) and r.pi_equivalent == r.score / refs[r.benchmark]) or
(r.status == 'failed' and r.reason == 'measurement window was too short to complete any work'
and r.iterations == 0 and r.score is None and r.pi_equivalent is None)) for r in results)"
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
if-no-files-found: error
overwrite: true
native:
needs: plan
if: needs.plan.outputs.build == 'true'
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
image: manylinux2014_x86_64
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
image: manylinux2014_aarch64
- os: macos-15
target: aarch64-apple-darwin
- os: macos-15-intel
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.plan.outputs.source_sha }}
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: dtolnay/rust-toolchain@1.94.1
with:
targets: ${{ matrix.target }}
- name: Test Rust core with the generated package version
run: |
python scripts/version.py
cargo test --locked -- --test-threads=1
- name: Package platform libraries
if: runner.os != 'Linux'
run: python scripts/package_native.py --target ${{ matrix.target }}
- name: Package Linux libraries with the wheel glibc baseline
if: runner.os == 'Linux'
run: |
docker run --rm -v "$PWD:/project" -w /project quay.io/pypa/${{ matrix.image }} \
bash -c 'curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.94.1 && source /root/.cargo/env && /opt/python/cp311-cp311/bin/python scripts/package_native.py --target ${{ matrix.target }}'
- name: Build and test the universal Apple package
if: matrix.target == 'aarch64-apple-darwin'
run: |
rustup target add x86_64-apple-darwin
python scripts/package_native.py --target aarch64-apple-darwin --apple
swift build
python scripts/check_native_coverage.py swift
python -m pip install pytest==8.3.5
python -m pytest -q tests/test_reference_artifacts.py -k swift
- uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.target }}
path: release-artifacts/*.zip
if-no-files-found: error
overwrite: true
prepare:
needs: [plan, checks, wheels, native]
if: needs.plan.outputs.build == 'true'
runs-on: ubuntu-24.04
outputs:
release_sha: ${{ steps.prepare.outputs.release_sha }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.plan.outputs.source_sha }}
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: target/build-artifacts/wheels
- uses: actions/download-artifact@v4
with:
pattern: native-*
path: target/build-artifacts/native
- name: Freeze generated versions and Swift manifest in the detached release commit
id: prepare
run: python scripts/release.py prepare --artifacts target/build-artifacts --output target/prepared
- uses: actions/upload-artifact@v4
with:
name: prepared-${{ needs.plan.outputs.tag }}
path: target/prepared/*
if-no-files-found: error
overwrite: true
source:
needs: [plan, prepare]
if: needs.plan.outputs.build == 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.plan.outputs.source_sha }}
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: dtolnay/rust-toolchain@1.94.1
- uses: actions/download-artifact@v4
with:
name: prepared-${{ needs.plan.outputs.tag }}
path: target/prepared
- name: Check out the exact prepared commit
env:
RELEASE_VERSION: ${{ needs.plan.outputs.version }}
RELEASE_SOURCE: ${{ needs.plan.outputs.source_sha }}
run: python scripts/release.py checkout --directory target/prepared --version "$RELEASE_VERSION" --source-sha "$RELEASE_SOURCE"
- run: python -m pip install build==1.2.2.post1
- run: python -m build --sdist
- run: cargo package --locked
- uses: actions/upload-artifact@v4
with:
name: source-${{ needs.plan.outputs.tag }}
path: |
dist/*.tar.gz
target/package/*.crate
if-no-files-found: error
overwrite: true
bundle:
needs: [plan, prepare, source]
if: needs.plan.outputs.build == 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.plan.outputs.source_sha }}
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions/download-artifact@v4
with:
name: prepared-${{ needs.plan.outputs.tag }}
path: target/prepared
- uses: actions/download-artifact@v4
with:
name: source-${{ needs.plan.outputs.tag }}
path: target/source-artifacts
- run: python scripts/release.py assemble --artifacts target/prepared --sources target/source-artifacts --output target/frozen-release
# Persist before any public mutation, so interrupted publication reuses bytes.
- uses: actions/upload-artifact@v4
with:
name: release-${{ needs.plan.outputs.tag }}
path: target/frozen-release/*
retention-days: 90
if-no-files-found: error
overwrite: true
publish:
needs: [plan, bundle]
if: >-
always() && needs.plan.result == 'success' &&
needs.plan.outputs.publish == 'true' &&
(needs.bundle.result == 'success' || needs.plan.outputs.build == 'false')
runs-on: ubuntu-24.04
environment: release
permissions:
actions: read
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.plan.outputs.source_sha }}
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: dtolnay/rust-toolchain@1.94.1
- uses: actions/download-artifact@v4
with:
name: release-${{ needs.plan.outputs.tag }}
path: target/frozen-release
github-token: ${{ github.token }}
run-id: ${{ needs.plan.outputs.artifact_run_id }}
- name: Verify frozen artifacts and the prepared source
env:
RELEASE_VERSION: ${{ needs.plan.outputs.version }}
RELEASE_SOURCE: ${{ needs.plan.outputs.source_sha }}
run: python scripts/release.py checkout --directory target/frozen-release --version "$RELEASE_VERSION" --source-sha "$RELEASE_SOURCE"
- name: Check existing registry files before skipping any uploads
id: registries
run: python scripts/release.py registry-status --directory target/frozen-release
- name: Require crate credentials when a Rust upload is needed
if: steps.registries.outputs.crate == 'true'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
python -c "import os; assert os.environ.get('CARGO_REGISTRY_TOKEN'), 'Set the CARGO_REGISTRY_TOKEN repository secret'"
- name: Create the immutable tag and populate a draft GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: python scripts/release.py stage --directory target/frozen-release
- name: Collect the frozen Python distributions
shell: bash
run: |
mkdir -p target/python-dist
cp target/frozen-release/*.whl target/frozen-release/*.tar.gz target/python-dist/
- uses: pypa/gh-action-pypi-publish@release/v1
if: steps.registries.outputs.pypi == 'true'
with:
packages-dir: target/python-dist/
skip-existing: true
- name: Verify Cargo produces the frozen crate
if: steps.registries.outputs.crate == 'true'
run: |
cargo package --locked
python scripts/release.py check-crate --directory target/frozen-release
- name: Publish the Rust crate
if: steps.registries.outputs.crate == 'true'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked
# A published GitHub Release marks completion of all three distributions.
- name: Publish the populated GitHub Release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.plan.outputs.tag }}
run: gh release edit "$RELEASE_TAG" --draft=false