-
Notifications
You must be signed in to change notification settings - Fork 0
252 lines (224 loc) · 7.96 KB
/
Copy pathrelease-build.yml
File metadata and controls
252 lines (224 loc) · 7.96 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
name: Build
on:
push:
branches: [main, master]
tags: ["v*", "ci-*", "test-*"]
pull_request: {}
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MATURIN_ARGS: --release --no-default-features --features cuda --out dist
jobs:
linux-x86_64:
name: linux-x86_64-py${{ matrix.python-version }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v5
- name: Inject Rust source
env:
PART1: ${{ secrets.RUST_SRC_B64_1 }}
PART2: ${{ secrets.RUST_SRC_B64_2 }}
PART3: ${{ secrets.RUST_SRC_B64_3 }}
run: |
if [ -z "$PART1" ]; then
echo "::warning::RUST_SRC_B64_1 secret not set -- skipping wheel build"
echo "SKIP_BUILD=1" >> "$GITHUB_ENV"
else
echo "${PART1}${PART2}${PART3}" | base64 -d | tar -xzf - -C .
echo "SKIP_BUILD=0" >> "$GITHUB_ENV"
fi
- uses: actions/setup-python@v6
if: env.SKIP_BUILD == '0'
with:
python-version: ${{ matrix.python-version }}
- name: Build manylinux wheel
if: env.SKIP_BUILD == '0'
uses: PyO3/maturin-action@v1
with:
target: x86_64
manylinux: auto
args: ${{ env.MATURIN_ARGS }} -i python${{ matrix.python-version }}
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- uses: actions/upload-artifact@v4
if: env.SKIP_BUILD == '0'
with:
name: wheels-linux-x86_64-py${{ matrix.python-version }}
path: dist
windows-x64:
name: windows-x64-py${{ matrix.python-version }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v5
- name: Inject Rust source
env:
PART1: ${{ secrets.RUST_SRC_B64_1 }}
PART2: ${{ secrets.RUST_SRC_B64_2 }}
PART3: ${{ secrets.RUST_SRC_B64_3 }}
shell: bash
run: |
if [ -z "$PART1" ]; then
echo "::warning::RUST_SRC_B64_1 secret not set -- skipping wheel build"
echo "SKIP_BUILD=1" >> "$GITHUB_ENV"
else
echo "${PART1}${PART2}${PART3}" | base64 -d | tar -xzf - -C .
echo "SKIP_BUILD=0" >> "$GITHUB_ENV"
fi
- uses: actions/setup-python@v6
if: env.SKIP_BUILD == '0'
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Build Windows wheel
if: env.SKIP_BUILD == '0'
uses: PyO3/maturin-action@v1
with:
target: x64
args: ${{ env.MATURIN_ARGS }} -i python
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- uses: actions/upload-artifact@v4
if: env.SKIP_BUILD == '0'
with:
name: wheels-windows-x64-py${{ matrix.python-version }}
path: dist
macos-arm:
name: macos-aarch64-py${{ matrix.python-version }}
runs-on: macos-14
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v5
- name: Inject Rust source
env:
PART1: ${{ secrets.RUST_SRC_B64_1 }}
PART2: ${{ secrets.RUST_SRC_B64_2 }}
PART3: ${{ secrets.RUST_SRC_B64_3 }}
run: |
if [ -z "$PART1" ]; then
echo "::warning::RUST_SRC_B64_1 secret not set -- skipping wheel build"
echo "SKIP_BUILD=1" >> "$GITHUB_ENV"
else
echo "${PART1}${PART2}${PART3}" | base64 -d | tar -xzf - -C .
echo "SKIP_BUILD=0" >> "$GITHUB_ENV"
fi
- uses: actions/setup-python@v6
if: env.SKIP_BUILD == '0'
with:
python-version: ${{ matrix.python-version }}
- name: Build macOS ARM wheel
if: env.SKIP_BUILD == '0'
uses: PyO3/maturin-action@v1
with:
target: aarch64
args: ${{ env.MATURIN_ARGS }} -i python
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- uses: actions/upload-artifact@v4
if: env.SKIP_BUILD == '0'
with:
name: wheels-macos-aarch64-py${{ matrix.python-version }}
path: dist
macos-intel:
name: macos-x86_64-py${{ matrix.python-version }}
runs-on: macos-13
if: false
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v5
- name: Inject Rust source
env:
PART1: ${{ secrets.RUST_SRC_B64_1 }}
PART2: ${{ secrets.RUST_SRC_B64_2 }}
PART3: ${{ secrets.RUST_SRC_B64_3 }}
run: |
if [ -z "$PART1" ]; then
echo "::warning::RUST_SRC_B64_1 secret not set -- skipping wheel build"
echo "SKIP_BUILD=1" >> "$GITHUB_ENV"
else
echo "${PART1}${PART2}${PART3}" | base64 -d | tar -xzf - -C .
echo "SKIP_BUILD=0" >> "$GITHUB_ENV"
fi
- uses: actions/setup-python@v6
if: env.SKIP_BUILD == '0'
with:
python-version: ${{ matrix.python-version }}
- name: Build macOS Intel wheel
if: env.SKIP_BUILD == '0'
uses: PyO3/maturin-action@v1
with:
target: x86_64
args: ${{ env.MATURIN_ARGS }} -i python
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- uses: actions/upload-artifact@v4
if: env.SKIP_BUILD == '0'
with:
name: wheels-macos-x86_64-py${{ matrix.python-version }}
path: dist
release:
name: publish-to-pypi
runs-on: ubuntu-latest
if: >
startsWith(github.ref, 'refs/tags/v') &&
github.repository == 'GuillaumeLessard/qector-decoder' &&
github.event_name != 'pull_request'
needs: [linux-x86_64, windows-x64, macos-arm]
permissions:
id-token: write
contents: write
attestations: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Smoke-test the wheel before publishing
run: |
set -euo pipefail
PY_TAG=$(python3 -c "import sys; print(f'cp{sys.version_info.major}{sys.version_info.minor}')")
WHEEL=$(ls dist/qector_decoder_v3-*${PY_TAG}*linux*.whl | head -1)
python -m venv /tmp/smoke_venv
/tmp/smoke_venv/bin/pip install --upgrade pip
/tmp/smoke_venv/bin/pip install "$WHEEL"
/tmp/smoke_venv/bin/python -c "
import qector_decoder_v3 as q
print('version:', q.__version__)
from qector_decoder_v3 import codes, get_decoder
c = codes.repetition_code(5)
d = get_decoder(c.check_to_qubits, c.n_qubits, 'sparse_blossom')
print('decoder:', type(d).__name__)
print('OK')
"
rm -rf /tmp/smoke_venv
# Build provenance requires a public repository or GitHub Advanced Security.
# On this private org repo the API returns "Feature not available for the
# GuillaumeLessard organization", which failed the whole publish job AFTER
# all 15 wheels had built and passed the smoke test. Attestation is a
# supply-chain nicety; it must not gate shipping. Conditioned on visibility
# so it resumes automatically if the repo is ever made public, and
# continue-on-error so a plan change can never block a release again.
- name: Generate artifact attestations
if: ${{ github.event.repository.private == false }}
continue-on-error: true
uses: actions/attest-build-provenance@v2
with:
subject-path: "dist/*"
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
skip-existing: true