|
| 1 | +name: Build and Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "v*" |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_wheels: |
| 11 | + name: Build wheels on ${{ matrix.os }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 16 | + |
| 17 | + env: |
| 18 | + # ---- Linux ---- |
| 19 | + # Build manylinux + musllinux wheels |
| 20 | + CIBW_ARCHS_LINUX: "x86_64" |
| 21 | + CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014" |
| 22 | + CIBW_MUSLLINUX_X86_64_IMAGE: "musllinux_1_2" |
| 23 | + |
| 24 | + # ---- macOS ---- |
| 25 | + # Build Intel, Apple Silicon, and universal2 wheels |
| 26 | + CIBW_ARCHS_MACOS: "x86_64 arm64 universal2" |
| 27 | + |
| 28 | + # ---- Windows ---- |
| 29 | + # Build both 32-bit and 64-bit wheels |
| 30 | + CIBW_ARCHS_WINDOWS: "AMD64 x86" |
| 31 | + |
| 32 | + # ---- General settings ---- |
| 33 | + # Build wheels for CPython 3.11–3.13 |
| 34 | + CIBW_BUILD: "cp311-* cp312-* cp313-*" |
| 35 | + |
| 36 | + # If needed, skip PyPy or unsupported combos |
| 37 | + CIBW_SKIP: "pp* *-manylinux_i686" |
| 38 | + |
| 39 | + # Output |
| 40 | + CIBW_OUTPUT_DIR: "wheelhouse" |
| 41 | + |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Install cibuildwheel |
| 46 | + run: pip install cibuildwheel==2.22.0 |
| 47 | + |
| 48 | + - name: Build wheels |
| 49 | + run: cibuildwheel |
| 50 | + |
| 51 | + - name: Upload wheels as artifacts |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: wheels-${{ matrix.os }} |
| 55 | + path: wheelhouse/*.whl |
| 56 | + |
| 57 | + build_sdist: |
| 58 | + name: Build sdist |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Build sdist |
| 64 | + run: | |
| 65 | + pip install build |
| 66 | + python -m build --sdist |
| 67 | +
|
| 68 | + - uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: sdist |
| 71 | + path: dist/*.tar.gz |
| 72 | + |
| 73 | + publish: |
| 74 | + name: Publish to PyPI |
| 75 | + needs: [build_wheels, build_sdist] |
| 76 | + runs-on: ubuntu-latest |
| 77 | + steps: |
| 78 | + - uses: actions/download-artifact@v4 |
| 79 | + |
| 80 | + - name: Install Twine |
| 81 | + run: pip install twine |
| 82 | + |
| 83 | + - name: Publish to PyPI |
| 84 | + run: | |
| 85 | + twine upload wheels-*/* sdist/* |
| 86 | + env: |
| 87 | + TWINE_USERNAME: "__token__" |
| 88 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments