name: Build & publish Python wheels
on:
push:
branches: [main]
tags:
- v*
pull_request:
branches: [main]
paths:
- src/**
- pyproject.toml
- Cargo.toml
- Cargo.lock
- .github/workflows/python.yml
- .github/workflows/python-build.yml
- test_ridal_interface.py
workflow_dispatch:
jobs:
build-pr:
name: Build PR (ubuntu / python 3.12)
if: github.event_name == 'pull_request'
uses: ./.github/workflows/python-build.yml
with:
os: ubuntu-latest
python-version: '3.12'
dry-run-publish:
name: Dry-run publish
needs: build-pr
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
contents: read
steps:
- name: Download wheels
uses: actions/download-artifact@v4
with:
path: wheels
- name: Dry-run publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
pip install uv
uv publish --dry-run wheels/**/*.whl
build-all:
name: Build all platforms
if: github.event_name != 'pull_request'
uses: ./.github/workflows/python-build.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
python-version: ['3.10', '3.11', '3.12', '3.13']
publish:
name: Publish to PyPI
needs: build-all
runs-on: ubuntu-latest
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch'
permissions:
contents: read
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
path: wheels
- name: Publish to PyPI
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
pip install uv
uv publish --check-url https://pypi.org/simple/ wheels/**/*.whl