Skip to content

Commit 25c6f58

Browse files
authored
create wheels for multiple Python version and OS support (#297)
1 parent 5ad64c6 commit 25c6f58

File tree

2 files changed

+52
-17
lines changed

2 files changed

+52
-17
lines changed

.github/workflows/pypi.yml

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,64 @@
1-
name: Publish to PyPI
1+
name: Build and publish wheels to PyPI
22

33
on:
44
push:
55
tags:
6-
- "v*" # Run only on version tags (e.g., v1.0.0)
6+
- "v*"
77

88
jobs:
99
build:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-latest, windows-latest]
14+
python: ["3.10", "3.11", "3.12"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: PyO3/maturin-action@v1
20+
with:
21+
python-version: ${{ matrix.python }}
22+
manylinux: auto
23+
command: build --release
24+
25+
- name: Upload wheels as artifacts
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: wheels-${{ matrix.os }}-py${{ matrix.python }}
29+
path: target/wheels/*.whl
30+
31+
sdist:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- uses: PyO3/maturin-action@v1
37+
with:
38+
python-version: "3.12" # Any version is fine
39+
command: sdist
40+
41+
- name: Upload sdist as artifact
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: sdist
45+
path: target/wheels/*.tar.gz
46+
47+
publish:
48+
needs: [build, sdist]
1049
runs-on: ubuntu-latest
1150
permissions:
1251
id-token: write
1352
steps:
14-
- uses: actions/checkout@v4
15-
- name: Set up Python
16-
uses: actions/setup-python@v5
53+
- uses: actions/download-artifact@v4
1754
with:
18-
python-version: "3.12"
19-
- name: Install Rust toolchain
20-
uses: dtolnay/rust-toolchain@stable
21-
- name: Install Poetry and Maturin
55+
path: dist
56+
- name: Flatten wheels and sdists
2257
run: |
23-
curl -sSL https://install.python-poetry.org | python3 -
24-
echo "$HOME/.local/bin" >> $GITHUB_PATH
25-
pip install maturin
26-
- name: Build Rust package
27-
run: maturin build --release
28-
- name: Publish package distributions to PyPI
29-
run: maturin publish
58+
mkdir -p upload
59+
find dist -type f \( -name "*.whl" -o -name "*.tar.gz" \) -exec cp {} upload/ \;
60+
61+
- name: Publish to PyPI
62+
uses: pypa/gh-action-pypi-publish@release/v1
63+
with:
64+
packages-dir: upload/

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
uses: actions-rs/toolchain@v1
4343
with:
4444
toolchain: stable
45-
profile: minimal
45+
override: true
4646

4747
# Step 6: Install Python Dependencies using Poetry
4848
- name: Install dependencies

0 commit comments

Comments
 (0)