|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_wheels: |
| 11 | + name: Build wheels on ${{ matrix.os }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + # macos-13 is an intel runner, macos-14 is apple silicon |
| 16 | + os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Install uv |
| 22 | + uses: astral-sh/setup-uv@v5 |
| 23 | + |
| 24 | + - name: Build wheels |
| 25 | + uses: pypa/cibuildwheel@v2.22.0 |
| 26 | + |
| 27 | + - uses: actions/upload-artifact@v4 |
| 28 | + with: |
| 29 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 30 | + path: ./wheelhouse/*.whl |
| 31 | + |
| 32 | + build_sdist: |
| 33 | + name: Build sdist |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Build sdist |
| 39 | + run: pipx run build --sdist |
| 40 | + |
| 41 | + - uses: actions/upload-artifact@v4 |
| 42 | + with: |
| 43 | + name: cibw-sdist |
| 44 | + path: dist/*.tar.gz |
| 45 | + |
| 46 | + publish: |
| 47 | + needs: [build_wheels, build_sdist] |
| 48 | + environment: pypi |
| 49 | + permissions: |
| 50 | + id-token: write # https://docs.pypi.org/trusted-publishers/using-a-publisher/#github-actions |
| 51 | + contents: write # Required for creating a release |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + - name: Checkout code |
| 55 | + uses: actions/checkout@v4 |
| 56 | + with: |
| 57 | + fetch-depth: 0 # Required for changelog |
| 58 | + |
| 59 | + - uses: actions/download-artifact@v4 |
| 60 | + with: |
| 61 | + pattern: cibw-* |
| 62 | + path: dist |
| 63 | + merge-multiple: true |
| 64 | + |
| 65 | + - name: Upload to PyPI |
| 66 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 67 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 68 | + with: |
| 69 | + skip-existing: true |
| 70 | + |
| 71 | + - name: Generate changelog with git-cliff |
| 72 | + uses: tj-actions/git-cliff@v1 |
| 73 | + with: |
| 74 | + args: --latest --strip all |
| 75 | + output: "CHANGELOG.md" |
| 76 | + |
| 77 | + - name: Create Github release |
| 78 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 79 | + uses: ncipollo/release-action@v1 |
| 80 | + with: |
| 81 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + bodyFile: "CHANGELOG.md" |
| 83 | + draft: false |
| 84 | + prerelease: false |
0 commit comments