|
1 |
| -name: Publish to PyPI |
| 1 | +name: Build and publish wheels to PyPI |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | tags:
|
6 |
| - - "v*" # Run only on version tags (e.g., v1.0.0) |
| 6 | + - "v*" |
7 | 7 |
|
8 | 8 | jobs:
|
9 | 9 | 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] |
10 | 49 | runs-on: ubuntu-latest
|
11 | 50 | permissions:
|
12 | 51 | id-token: write
|
13 | 52 | steps:
|
14 |
| - - uses: actions/checkout@v4 |
15 |
| - - name: Set up Python |
16 |
| - uses: actions/setup-python@v5 |
| 53 | + - uses: actions/download-artifact@v4 |
17 | 54 | 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 |
22 | 57 | 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/ |
0 commit comments