|
| 1 | +name: Release Python |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "*" |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + paths: |
| 11 | + - ".github/workflows/python_release.yml" |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + windows: |
| 19 | + runs-on: ${{ matrix.platform.runner }} |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + platform: |
| 23 | + - runner: windows-latest |
| 24 | + target: x64 |
| 25 | + - runner: windows-latest |
| 26 | + target: x86 |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + - uses: actions/setup-python@v5 |
| 30 | + with: |
| 31 | + python-version: 3.x |
| 32 | + architecture: ${{ matrix.platform.target }} |
| 33 | + - name: Build wheels |
| 34 | + uses: PyO3/maturin-action@v1 |
| 35 | + with: |
| 36 | + target: ${{ matrix.platform.target }} |
| 37 | + args: --release --out dist --bindings pyo3 --features=pyo3/extension-module |
| 38 | + sccache: "true" |
| 39 | + working-directory: "bindings/python" |
| 40 | + - name: Upload wheels |
| 41 | + uses: actions/upload-artifact@v4 |
| 42 | + with: |
| 43 | + name: wheels-windows-${{ matrix.platform.target }} |
| 44 | + path: bindings/python/dist |
| 45 | + |
| 46 | + macos: |
| 47 | + runs-on: ${{ matrix.platform.runner }} |
| 48 | + strategy: |
| 49 | + matrix: |
| 50 | + platform: |
| 51 | + - runner: macos-12 |
| 52 | + target: x86_64 |
| 53 | + - runner: macos-14 |
| 54 | + target: aarch64 |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + - uses: actions/setup-python@v5 |
| 58 | + with: |
| 59 | + python-version: 3.x |
| 60 | + - name: Build wheels |
| 61 | + uses: PyO3/maturin-action@v1 |
| 62 | + with: |
| 63 | + target: ${{ matrix.platform.target }} |
| 64 | + args: --release --out dist --bindings pyo3 --features=pyo3/extension-module |
| 65 | + sccache: "true" |
| 66 | + working-directory: "bindings/python" |
| 67 | + - name: Upload wheels |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: wheels-macos-${{ matrix.platform.target }} |
| 71 | + path: bindings/python/dist |
| 72 | + |
| 73 | + release: |
| 74 | + name: Release |
| 75 | + environment: release |
| 76 | + runs-on: ubuntu-latest |
| 77 | + if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} |
| 78 | + needs: [windows, macos] |
| 79 | + permissions: |
| 80 | + # Use to sign the release artifacts |
| 81 | + id-token: write |
| 82 | + # Used to upload release artifacts |
| 83 | + contents: write |
| 84 | + # Used to generate artifact attestation |
| 85 | + attestations: write |
| 86 | + steps: |
| 87 | + - uses: actions/download-artifact@v4 |
| 88 | + - name: Generate artifact attestation |
| 89 | + uses: actions/attest-build-provenance@v1 |
| 90 | + with: |
| 91 | + subject-path: "wheels-*/*" |
| 92 | + - name: Publish to PyPI |
| 93 | + if: "startsWith(github.ref, 'refs/tags/')" |
| 94 | + uses: PyO3/maturin-action@v1 |
| 95 | + with: |
| 96 | + command: upload |
| 97 | + args: --non-interactive --skip-existing wheels-*/* |
0 commit comments