name: Publish to PyPI # This workflow is triggered when you push a new version tag (e.g., v0.1.0, v1.2.3) on: push: tags: - 'v[0-9]+.[0-9]+.[0-9]+*' # Matches v0.1.0 or v1.0.0-rc1, etc. # Allows manual triggering from the GitHub Actions UI workflow_dispatch: jobs: build_wheels: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} # Define a matrix to build for common operating systems and architectures strategy: matrix: include: - os: ubuntu-latest target: x86_64 python: '3.12' - os: macos-latest target: x86_64 - os: windows-latest target: x86_64 steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.12' # Target a modern Python version - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - name: Build wheels with Maturin uses: PyO3/maturin-action@v1 with: # Use the target from the matrix (x86_64) target: ${{ matrix.target }} # Build a manylinux-compatible wheel for Linux/Colab users # manylinux: auto command: build args: --release --out dist --find-interpreter - name: Upload built wheels as Artifact uses: actions/upload-artifact@v4 with: name: wheels path: dist publish: name: Publish to PyPI needs: [build_wheels] runs-on: ubuntu-latest # This step will only run if the 'build_wheels' job completed successfully if: startsWith(github.ref, 'refs/tags/') steps: - uses: actions/download-artifact@v4 with: name: wheels path: dist - name: Publish to PyPI uses: PyO3/maturin-action@v1 with: # Use the secret we configured on GitHub pypi-token: ${{ secrets.PYPI_API_TOKEN }} # Command to upload all wheels in the 'dist' directory command: upload args: --skip-existing --non-interactive