name: Publish Python Package
on:
release:
types: [published]
workflow_dispatch: {}
env:
CARGO_TERM_COLOR: always
jobs:
validate:
name: Validate compilation
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Validate Python FFI compiles
run: cargo check --features python-ffi --locked
build:
name: Build & upload (Python ${{ matrix.python-version }}, ${{ matrix.arch }})
runs-on: ${{ matrix.os }}
needs: validate
permissions:
contents: read
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest]
arch: [x86_64]
include:
- python-version: "3.9"
os: ubuntu-24.04-arm
arch: aarch64
- python-version: "3.10"
os: ubuntu-24.04-arm
arch: aarch64
- python-version: "3.11"
os: ubuntu-24.04-arm
arch: aarch64
- python-version: "3.12"
os: ubuntu-24.04-arm
arch: aarch64
- python-version: "3.13"
os: ubuntu-24.04-arm
arch: aarch64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Install maturin
run: python -m pip install "maturin>=1.4,<2.0"
- name: Build wheel
run: python -m maturin build --release --features python-ffi --out dist --compatibility pypi
- name: List wheels
run: ls -la dist/
- name: Upload wheel to PyPI
run: pipx run twine upload --skip-existing --verbose dist/*.whl
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.MATURIN_PYPI_TOKEN }}