From f3d2260a50a0160284cf986ce7a18b1be2cf4aa5 Mon Sep 17 00:00:00 2001 From: BillTheMaker Date: Tue, 18 Nov 2025 17:50:35 -0700 Subject: [PATCH] Update GitHub Actions workflow for PyPI publishing feat(ci): Add automated publishing workflow to PyPI --- .github/workflows/publish.yml | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..c78ebd7 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,75 @@ +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 + - 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