-
Notifications
You must be signed in to change notification settings - Fork 0
256 lines (228 loc) · 8.46 KB
/
Copy pathCI.yml
File metadata and controls
256 lines (228 loc) · 8.46 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
# CI -- Build wheels on Linux/Windows/macOS (Intel x86_64 + ARM aarch64), publish to PyPI on tag.
#
# Rust source is injected at build time from three GitHub Actions secrets
# (RUST_SRC_B64_1 + RUST_SRC_B64_2 + RUST_SRC_B64_3) to keep the proprietary
# core private. Secrets are base64 chunks that reassemble to src.tar.gz.
# On forks / external PRs the secrets will be empty and wheel builds are skipped.
#
# Trigger: push to main/master, any tag v*, pull_request, manual dispatch.
name: CI
on:
push:
branches: [main, master]
tags: ["v*"]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# Build without OpenCL (SDK not on runners). CUDA is runtime-loaded via
# libloading so no CUDA toolkit is needed at build time.
MATURIN_ARGS: --release --no-default-features --features cuda --out dist
jobs:
# ------------------------------------------------------------------
# Linux x86_64 manylinux wheels
# ------------------------------------------------------------------
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 wheels
# ------------------------------------------------------------------
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 Apple Silicon (aarch64) wheels
# ------------------------------------------------------------------
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 (x86_64) wheels
# ------------------------------------------------------------------
macos-intel:
name: macos-x86_64-py${{ matrix.python-version }}
runs-on: macos-13
if: false # disabled for v0.6.2 release to avoid 8h+ queue; will re-enable later
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
# ------------------------------------------------------------------
# Publish to PyPI via OIDC Trusted Publisher (no token required)
# Runs only on version tags pushed to the main repo (not forks).
# Public releases are wheel-only to prevent unsupported interpreters from
# falling back to a source build without the proprietary Rust core.
# ------------------------------------------------------------------
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]
# Note: macos-intel (x86_64 on macos-13) is built but not required for publish
# due to long GitHub runner queues for Intel macOS. Artifacts can be attached manually if needed.
environment: pypi
permissions:
id-token: write
contents: write
attestations: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate artifact attestations
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