Skip to content

Commit 8894135

Browse files
authored
👷 Build free-threaded wheels on CI and upload to TestPyPI (#34)
* ⬆️ Bump actions/upload-artifact from 4.3.1 to 4.6.2 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.1 to 4.6.2. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v4.3.1...v4.6.2) * ⬆️ Bump maturin-action from 1.41.0 to 1.49.1 Bumps [PyO3/maturin-action](https://github.com/pyo3/maturin-action) from 1.41.0 to 1.49.1. - [Release notes](https://github.com/pyo3/maturin-action/releases) - [Commits](PyO3/maturin-action@v1.41.0...v1.49.1) * 👷 Build free-threaded wheels on CI Bump maturin from 1.4.0 to 1.8.7 locally, and re-generated the .github/workflows/ci.yml file. Main change was the addition of Python 3.13t free-threaded wheel builds (added in maturin 1.7.6, PyO3/maturin#2329). Have withheld musllinux builds for now, but changed to using macos-13 runner for x86_64 target. Included artifact attestation generation now too. * 💚 Fix win free-threaded whl build by installing 3.13t first Try installing Python 3.13t via actions/setup-python before the free-threaded wheels build step, to see if it fixes the error "Caused by: Need a Python interpreter to compile for Windows without PyO3's `generate-import-lib` feature`; Caused by: Python interpreter `python3.13t` doesn't exist". Also fixed a typo in the target field. * ⬆️ Bump actions/setup-python from 5.0.0 to 5.6.0 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.0.0 to 5.6.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v5.0.0...v5.6.0) * 👷 Setup Publish to TestPyPI job to run on push/tag Based on https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#separate-workflow-for-publishing-to-testpypi. Also refactored the publish-to-pypi step to use a similar setup, removing the attestation step since that should be covered by pypa/gh-action-pypi-publish already. * 👷 Publish to TestPyPI on prereleased event trigger Couldn't figure out an elegant way to dynamically update the version every push to the main branch, so settling for just uploading to TestPyPI on pre-release event triggers (xref https://github.com/orgs/community/discussions/26281). Publish to PyPI will only happen on actual releases. * 📌 Set version to 0.0.1-beta.1 Downgrading to a pre-release version tag until confident.
1 parent 8a7e6a9 commit 8894135

File tree

4 files changed

+106
-45
lines changed

4 files changed

+106
-45
lines changed

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
persist-credentials: false
3636

3737
# Setup Python interpreter
38-
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
38+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
3939
with:
4040
python-version: "3.12"
4141

.github/workflows/ci.yml

Lines changed: 103 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file is autogenerated by maturin v1.4.0
1+
# This file is autogenerated by maturin v1.8.7
22
# To update, run
33
#
44
# maturin generate-ci --pytest github
@@ -62,30 +62,39 @@ jobs:
6262
with:
6363
persist-credentials: false
6464

65-
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
65+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
6666
with:
6767
python-version: "3.12"
6868

6969
- name: Build wheels
70-
uses: PyO3/maturin-action@60d11847b29f81ca5375519a8eb33cc336ba4bfa # v1.41.0
70+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
7171
with:
7272
target: ${{ matrix.platform.target }}
73-
args: --release --out dist --find-interpreter
74-
container: ghcr.io/rust-cross/manylinux_2_28-cross:${{ matrix.platform.target }}
75-
sccache: "true"
73+
args: --release --out dist
74+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
75+
manylinux: "2_28"
76+
77+
- name: Build free-threaded wheels
78+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
79+
with:
80+
target: ${{ matrix.platform.target }}
81+
args: --release --out dist --interpreter python3.13t
82+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
7683
manylinux: "2_28"
7784

7885
- name: Upload wheels
79-
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
86+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
8087
with:
8188
name: wheels-linux-${{ matrix.platform.target }}
82-
path: dist
89+
path: dist/
8390

8491
- name: pytest
8592
if: ${{ endswith(matrix.platform.target, '64') }} # x86_64 and aarch64
8693
shell: bash
8794
run: |
8895
set -e
96+
python3 -m venv .venv
97+
source .venv/bin/activate
8998
pip install cog3pio[tests] --find-links dist --force-reinstall
9099
pytest --verbose
91100
@@ -104,9 +113,10 @@ jobs:
104113
run: |
105114
set -e
106115
python3 -m venv .venv
107-
.venv/bin/pip3 install -U pip pytest
108-
.venv/bin/pip3 install cog3pio --find-links dist --force-reinstall
109-
.venv/bin/pytest --verbose
116+
source .venv/bin/activate
117+
pip3 install -U pip
118+
pip3 install cog3pio[tests] --find-links dist --force-reinstall
119+
pytest --verbose
110120
111121
windows:
112122
runs-on: windows-2025
@@ -119,64 +129,89 @@ jobs:
119129
with:
120130
persist-credentials: false
121131

122-
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
132+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
123133
with:
124134
python-version: "3.12"
125135
architecture: ${{ matrix.target }}
126136

127137
- name: Build wheels
128-
uses: PyO3/maturin-action@60d11847b29f81ca5375519a8eb33cc336ba4bfa # v1.41.0
138+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
129139
with:
130140
target: ${{ matrix.target }}
131-
args: --release --out dist --find-interpreter
132-
sccache: "true"
141+
args: --release --out dist
142+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
143+
144+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
145+
with:
146+
python-version: "3.13t"
147+
architecture: ${{ matrix.target }}
148+
149+
- name: Build free-threaded wheels
150+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
151+
with:
152+
target: ${{ matrix.target }}
153+
args: --release --out dist -i python3.13t
154+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
133155

134156
- name: Upload wheels
135-
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
157+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
136158
with:
137159
name: wheels-windows-${{ matrix.target }}
138-
path: dist
160+
path: dist/
139161

140162
- name: pytest
141163
shell: bash
142164
run: |
143165
set -e
166+
python3 -m venv .venv
167+
source .venv/Scripts/activate
144168
pip install cog3pio[tests] --find-links dist --force-reinstall
145169
pytest --verbose
146170
147171
macos:
148-
runs-on: macos-15
172+
runs-on: ${{ matrix.platform.runner }}
149173
strategy:
150174
matrix:
151-
target: [x86_64, aarch64]
175+
platform:
176+
- runner: macos-13
177+
target: x86_64
178+
- runner: macos-15
179+
target: aarch64
152180
steps:
153181
- name: Checkout repository
154182
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
155183
with:
156184
persist-credentials: false
157185

158-
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
186+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
159187
with:
160188
python-version: "3.12"
161189

162190
- name: Build wheels
163-
uses: PyO3/maturin-action@60d11847b29f81ca5375519a8eb33cc336ba4bfa # v1.41.0
191+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
164192
with:
165-
target: ${{ matrix.target }}
166-
args: --release --out dist --find-interpreter
167-
sccache: "true"
193+
target: ${{ matrix.platform.target }}
194+
args: --release --out dist
195+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
196+
197+
- name: Build free-threaded wheels
198+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
199+
with:
200+
target: ${{ matrix.platform.target }}
201+
args: --release --out dist -i python3.13t
202+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
168203

169204
- name: Upload wheels
170-
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
205+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
171206
with:
172-
name: wheels-macos-${{ matrix.target }}
173-
path: dist
207+
name: wheels-macos-${{ matrix.platform.target }}
208+
path: dist/
174209

175210
- name: pytest
176-
if: ${{ startsWith(matrix.target, 'aarch64') }}
177-
shell: bash
178211
run: |
179212
set -e
213+
python3 -m venv .venv
214+
source .venv/bin/activate
180215
pip install cog3pio[tests] --find-links dist --force-reinstall
181216
pytest --verbose
182217
@@ -189,30 +224,56 @@ jobs:
189224
persist-credentials: false
190225

191226
- name: Build sdist
192-
uses: PyO3/maturin-action@60d11847b29f81ca5375519a8eb33cc336ba4bfa # v1.41.0
227+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
193228
with:
194229
command: sdist
195230
args: --out dist
196231

197232
- name: Upload sdist
198-
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
233+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
199234
with:
200235
name: wheels-sdist
201-
path: dist
236+
path: dist/
202237

203-
release:
204-
name: Release
205-
runs-on: ubuntu-24.04
206-
if: "startsWith(github.ref, 'refs/tags/')"
238+
publish-to-testpypi:
239+
name: Publish Python 🐍 distribution 📦 to TestPyPI
240+
if: github.repository == 'weiji14/cog3pio' && (github.event_name == 'release' && (github.event.action == 'prereleased' || github.event.action == 'released'))
207241
needs: [linux, windows, macos, sdist]
242+
runs-on: ubuntu-24.04
243+
environment:
244+
name: testpypi
245+
url: https://test.pypi.org/project/cog3pio
246+
permissions:
247+
id-token: write # IMPORTANT: mandatory for trusted OIDC publishing
248+
208249
steps:
209250
- name: Download built wheels
210251
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
252+
with:
253+
path: dist/
254+
merge-multiple: true
211255

212-
- name: Publish to PyPI
213-
uses: PyO3/maturin-action@60d11847b29f81ca5375519a8eb33cc336ba4bfa # v1.41.0
214-
env:
215-
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
256+
- name: Publish distribution 📦 to TestPyPI
257+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
216258
with:
217-
command: upload
218-
args: --non-interactive --skip-existing wheels-*/*
259+
repository-url: https://test.pypi.org/legacy/
260+
261+
publish-to-pypi:
262+
name: Publish Python 🐍 distribution 📦 to PyPI
263+
runs-on: ubuntu-24.04
264+
environment:
265+
name: pypi
266+
url: https://pypi.org/project/cog3pio/
267+
if: github.repository == 'weiji14/cog3pio' && (github.event_name == 'release' && github.event.action == 'released')
268+
needs: [linux, windows, macos, sdist]
269+
permissions:
270+
id-token: write # IMPORTANT: mandatory for trusted OIDC publishing
271+
steps:
272+
- name: Download built wheels
273+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
274+
with:
275+
path: dist/
276+
merge-multiple: true
277+
278+
- name: Publish distribution 📦 to PyPI
279+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cog3pio"
3-
version = "0.1.0"
3+
version = "0.0.1-beta.1"
44
edition = "2024"
55
license = "MIT OR Apache-2.0"
66
rust-version = "1.85.0"

0 commit comments

Comments
 (0)