Skip to content

Commit e32ba34

Browse files
committed
feat(release): add PyPI publish workflow
1 parent 584f573 commit e32ba34

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
build-wheels:
10+
name: Build wheels (${{ matrix.platform }})
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- os: ubuntu-22.04
17+
platform: manylinux_x86_64
18+
target: x86_64-unknown-linux-gnu
19+
- os: ubuntu-22.04
20+
platform: manylinux_aarch64
21+
target: aarch64-unknown-linux-gnu
22+
cflags_aarch64: "-march=armv8-a -D__ARM_ARCH=8"
23+
- os: macos-13
24+
platform: macos_x86_64
25+
target: x86_64-apple-darwin
26+
- os: macos-14
27+
platform: macos_aarch64
28+
target: aarch64-apple-darwin
29+
- os: windows-2022
30+
platform: windows_x86_64
31+
target: x86_64-pc-windows-msvc
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: "3.11"
40+
41+
- name: Set ring flags (linux aarch64)
42+
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' && startsWith(matrix.platform, 'manylinux') }}
43+
run: |
44+
echo "CFLAGS_aarch64_unknown_linux_gnu=${{ matrix.cflags_aarch64 }}" >> $GITHUB_ENV
45+
46+
- name: Build wheels
47+
uses: PyO3/maturin-action@v1
48+
with:
49+
command: build
50+
args: --release --out dist -F python-ffi
51+
maturin-version: "1.5.1"
52+
manylinux: auto
53+
target: ${{ matrix.target }}
54+
55+
- name: Upload wheels
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: wheels-${{ matrix.platform }}
59+
path: dist/*.whl
60+
61+
sdist:
62+
name: Build sdist
63+
runs-on: ubuntu-22.04
64+
steps:
65+
- uses: actions/checkout@v4
66+
67+
- name: Set up Python
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: "3.11"
71+
72+
- name: Build sdist
73+
uses: PyO3/maturin-action@v1
74+
with:
75+
command: sdist
76+
args: --out dist -F python-ffi
77+
maturin-version: "1.5.1"
78+
79+
- name: Upload sdist
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: sdist
83+
path: dist/*.tar.gz
84+
85+
publish:
86+
name: Publish to PyPI
87+
runs-on: ubuntu-22.04
88+
needs: [build-wheels, sdist]
89+
steps:
90+
- uses: actions/checkout@v4
91+
92+
- name: Download artifacts
93+
uses: actions/download-artifact@v4
94+
with:
95+
pattern: "wheels-*"
96+
path: dist
97+
merge-multiple: true
98+
99+
- name: Download sdist
100+
uses: actions/download-artifact@v4
101+
with:
102+
name: sdist
103+
path: dist
104+
105+
- name: Publish
106+
uses: PyO3/maturin-action@v1
107+
env:
108+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
109+
with:
110+
command: upload
111+
args: --non-interactive --skip-existing dist/*
112+
maturin-version: "1.5.1"

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ pip install -e ".[test]"
157157
pytest python/tests
158158
```
159159

160+
### Release to PyPI
161+
162+
Push a version tag (e.g., v1.1.0) to trigger the publish workflow:
163+
164+
```bash
165+
git tag v1.1.0
166+
git push origin v1.1.0
167+
```
168+
160169
Example (maturin-style usage):
161170

162171
```python

0 commit comments

Comments
 (0)