Skip to content

Commit 2e4e083

Browse files
committed
ci: fresh release-build.yml with unique name
1 parent f44f185 commit 2e4e083

1 file changed

Lines changed: 242 additions & 0 deletions

File tree

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
tags: ["v*", "ci-*", "test-*"]
7+
pull_request: {}
8+
workflow_dispatch: {}
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
MATURIN_ARGS: --release --no-default-features --features cuda --out dist
19+
20+
jobs:
21+
linux-x86_64:
22+
name: linux-x86_64-py${{ matrix.python-version }}
23+
runs-on: ubuntu-22.04
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
28+
steps:
29+
- uses: actions/checkout@v5
30+
31+
- name: Inject Rust source
32+
env:
33+
PART1: ${{ secrets.RUST_SRC_B64_1 }}
34+
PART2: ${{ secrets.RUST_SRC_B64_2 }}
35+
PART3: ${{ secrets.RUST_SRC_B64_3 }}
36+
run: |
37+
if [ -z "$PART1" ]; then
38+
echo "::warning::RUST_SRC_B64_1 secret not set -- skipping wheel build"
39+
echo "SKIP_BUILD=1" >> "$GITHUB_ENV"
40+
else
41+
echo "${PART1}${PART2}${PART3}" | base64 -d | tar -xzf - -C .
42+
echo "SKIP_BUILD=0" >> "$GITHUB_ENV"
43+
fi
44+
45+
- uses: actions/setup-python@v6
46+
if: env.SKIP_BUILD == '0'
47+
with:
48+
python-version: ${{ matrix.python-version }}
49+
50+
- name: Build manylinux wheel
51+
if: env.SKIP_BUILD == '0'
52+
uses: PyO3/maturin-action@v1
53+
with:
54+
target: x86_64
55+
manylinux: auto
56+
args: ${{ env.MATURIN_ARGS }} -i python${{ matrix.python-version }}
57+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
58+
59+
- uses: actions/upload-artifact@v4
60+
if: env.SKIP_BUILD == '0'
61+
with:
62+
name: wheels-linux-x86_64-py${{ matrix.python-version }}
63+
path: dist
64+
65+
windows-x64:
66+
name: windows-x64-py${{ matrix.python-version }}
67+
runs-on: windows-latest
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
72+
steps:
73+
- uses: actions/checkout@v5
74+
75+
- name: Inject Rust source
76+
env:
77+
PART1: ${{ secrets.RUST_SRC_B64_1 }}
78+
PART2: ${{ secrets.RUST_SRC_B64_2 }}
79+
PART3: ${{ secrets.RUST_SRC_B64_3 }}
80+
shell: bash
81+
run: |
82+
if [ -z "$PART1" ]; then
83+
echo "::warning::RUST_SRC_B64_1 secret not set -- skipping wheel build"
84+
echo "SKIP_BUILD=1" >> "$GITHUB_ENV"
85+
else
86+
echo "${PART1}${PART2}${PART3}" | base64 -d | tar -xzf - -C .
87+
echo "SKIP_BUILD=0" >> "$GITHUB_ENV"
88+
fi
89+
90+
- uses: actions/setup-python@v6
91+
if: env.SKIP_BUILD == '0'
92+
with:
93+
python-version: ${{ matrix.python-version }}
94+
architecture: x64
95+
96+
- name: Build Windows wheel
97+
if: env.SKIP_BUILD == '0'
98+
uses: PyO3/maturin-action@v1
99+
with:
100+
target: x64
101+
args: ${{ env.MATURIN_ARGS }} -i python
102+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
103+
104+
- uses: actions/upload-artifact@v4
105+
if: env.SKIP_BUILD == '0'
106+
with:
107+
name: wheels-windows-x64-py${{ matrix.python-version }}
108+
path: dist
109+
110+
macos-arm:
111+
name: macos-aarch64-py${{ matrix.python-version }}
112+
runs-on: macos-14
113+
strategy:
114+
fail-fast: false
115+
matrix:
116+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
117+
steps:
118+
- uses: actions/checkout@v5
119+
120+
- name: Inject Rust source
121+
env:
122+
PART1: ${{ secrets.RUST_SRC_B64_1 }}
123+
PART2: ${{ secrets.RUST_SRC_B64_2 }}
124+
PART3: ${{ secrets.RUST_SRC_B64_3 }}
125+
run: |
126+
if [ -z "$PART1" ]; then
127+
echo "::warning::RUST_SRC_B64_1 secret not set -- skipping wheel build"
128+
echo "SKIP_BUILD=1" >> "$GITHUB_ENV"
129+
else
130+
echo "${PART1}${PART2}${PART3}" | base64 -d | tar -xzf - -C .
131+
echo "SKIP_BUILD=0" >> "$GITHUB_ENV"
132+
fi
133+
134+
- uses: actions/setup-python@v6
135+
if: env.SKIP_BUILD == '0'
136+
with:
137+
python-version: ${{ matrix.python-version }}
138+
139+
- name: Build macOS ARM wheel
140+
if: env.SKIP_BUILD == '0'
141+
uses: PyO3/maturin-action@v1
142+
with:
143+
target: aarch64
144+
args: ${{ env.MATURIN_ARGS }} -i python
145+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
146+
147+
- uses: actions/upload-artifact@v4
148+
if: env.SKIP_BUILD == '0'
149+
with:
150+
name: wheels-macos-aarch64-py${{ matrix.python-version }}
151+
path: dist
152+
153+
macos-intel:
154+
name: macos-x86_64-py${{ matrix.python-version }}
155+
runs-on: macos-13
156+
if: false
157+
strategy:
158+
fail-fast: false
159+
matrix:
160+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
161+
steps:
162+
- uses: actions/checkout@v5
163+
164+
- name: Inject Rust source
165+
env:
166+
PART1: ${{ secrets.RUST_SRC_B64_1 }}
167+
PART2: ${{ secrets.RUST_SRC_B64_2 }}
168+
PART3: ${{ secrets.RUST_SRC_B64_3 }}
169+
run: |
170+
if [ -z "$PART1" ]; then
171+
echo "::warning::RUST_SRC_B64_1 secret not set -- skipping wheel build"
172+
echo "SKIP_BUILD=1" >> "$GITHUB_ENV"
173+
else
174+
echo "${PART1}${PART2}${PART3}" | base64 -d | tar -xzf - -C .
175+
echo "SKIP_BUILD=0" >> "$GITHUB_ENV"
176+
fi
177+
178+
- uses: actions/setup-python@v6
179+
if: env.SKIP_BUILD == '0'
180+
with:
181+
python-version: ${{ matrix.python-version }}
182+
183+
- name: Build macOS Intel wheel
184+
if: env.SKIP_BUILD == '0'
185+
uses: PyO3/maturin-action@v1
186+
with:
187+
target: x86_64
188+
args: ${{ env.MATURIN_ARGS }} -i python
189+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
190+
191+
- uses: actions/upload-artifact@v4
192+
if: env.SKIP_BUILD == '0'
193+
with:
194+
name: wheels-macos-x86_64-py${{ matrix.python-version }}
195+
path: dist
196+
197+
release:
198+
name: publish-to-pypi
199+
runs-on: ubuntu-latest
200+
if: >
201+
startsWith(github.ref, 'refs/tags/v') &&
202+
github.repository == 'GuillaumeLessard/qector-decoder' &&
203+
github.event_name != 'pull_request'
204+
needs: [linux-x86_64, windows-x64, macos-arm]
205+
environment: pypi
206+
permissions:
207+
id-token: write
208+
contents: write
209+
attestations: write
210+
steps:
211+
- uses: actions/download-artifact@v4
212+
with:
213+
path: dist
214+
merge-multiple: true
215+
216+
- name: Smoke-test the wheel before publishing
217+
run: |
218+
set -euo pipefail
219+
WHEEL=$(echo dist/qector_decoder_v3-*.whl | cut -d' ' -f1)
220+
python -m venv /tmp/smoke_venv
221+
/tmp/smoke_venv/bin/pip install "$WHEEL"
222+
/tmp/smoke_venv/bin/python -c "
223+
import qector_decoder_v3 as q
224+
print('version:', q.__version__)
225+
from qector_decoder_v3 import codes, sinter_compat
226+
c = codes.repetition_code(5)
227+
d = c.make_decoder('sparse_blossom')
228+
print('decoder:', type(d).__name__)
229+
print('OK')
230+
"
231+
rm -rf /tmp/smoke_venv
232+
233+
- name: Generate artifact attestations
234+
uses: actions/attest-build-provenance@v2
235+
with:
236+
subject-path: "dist/*"
237+
238+
- name: Publish to PyPI
239+
uses: pypa/gh-action-pypi-publish@release/v1
240+
with:
241+
packages-dir: dist/
242+
skip-existing: true

0 commit comments

Comments
 (0)