Build & Publish Python Wheels #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Publish Python Wheels | |
| # Triggers on push of a version tag like v0.1.0 | |
| on: | |
| push: | |
| tags: | |
| - 'py-v*' | |
| workflow_dispatch: # Also allows manual trigger | |
| permissions: | |
| contents: read | |
| jobs: | |
| # ──────────────────────────────────────────────── | |
| # 1. Build wheels for all platforms in parallel | |
| # ──────────────────────────────────────────────── | |
| build-wheels: | |
| name: Build wheels (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install maturin | |
| run: pip install maturin | |
| - name: Build wheels | |
| run: maturin build --release --out dist | |
| working-directory: ferrumdb-python | |
| - name: Upload wheels as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }} | |
| path: ferrumdb-python/dist/*.whl | |
| # ──────────────────────────────────────────────── | |
| # 2. Build source distribution (sdist) | |
| # ──────────────────────────────────────────────── | |
| build-sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install maturin | |
| run: pip install maturin | |
| - name: Build sdist | |
| run: maturin sdist --out dist | |
| working-directory: ferrumdb-python | |
| - name: Upload sdist | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: ferrumdb-python/dist/*.tar.gz | |
| # ──────────────────────────────────────────────── | |
| # 3. Publish everything to PyPI | |
| # ──────────────────────────────────────────────── | |
| publish: | |
| name: Publish to PyPI | |
| needs: [build-wheels, build-sdist] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/ | |
| password: ${{ secrets.PYPI_API_TOKEN }} |