|
| 1 | +name: Build and upload to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - edited |
| 7 | + release: |
| 8 | + types: |
| 9 | + - published |
| 10 | + |
| 11 | +jobs: |
| 12 | + # Build the wheels for Linux, Windows and macOS for Python 3.9 and newer |
| 13 | + build_wheels: |
| 14 | + name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + # Ensure that a wheel builder finishes even if another fails |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + include: |
| 21 | + # Window 64 bit |
| 22 | + - os: windows-latest |
| 23 | + python: 39 |
| 24 | + platform_id: win_amd64 |
| 25 | + - os: windows-latest |
| 26 | + python: 310 |
| 27 | + platform_id: win_amd64 |
| 28 | + - os: windows-latest |
| 29 | + python: 311 |
| 30 | + platform_id: win_amd64 |
| 31 | + - os: windows-latest |
| 32 | + python: 312 |
| 33 | + platform_id: win_amd64 |
| 34 | + - os: windows-latest |
| 35 | + python: 313 |
| 36 | + platform_id: win_amd64 |
| 37 | + - os: windows-latest |
| 38 | + python: 313t |
| 39 | + platform_id: win_amd64 |
| 40 | + free_threaded_support: True |
| 41 | + |
| 42 | + # Linux 64 bit manylinux2014 |
| 43 | + - os: ubuntu-latest |
| 44 | + python: 39 |
| 45 | + platform_id: manylinux_x86_64 |
| 46 | + - os: ubuntu-latest |
| 47 | + python: 310 |
| 48 | + platform_id: manylinux_x86_64 |
| 49 | + - os: ubuntu-latest |
| 50 | + python: 311 |
| 51 | + platform_id: manylinux_x86_64 |
| 52 | + - os: ubuntu-latest |
| 53 | + python: 312 |
| 54 | + platform_id: manylinux_x86_64 |
| 55 | + - os: ubuntu-latest |
| 56 | + python: 313 |
| 57 | + platform_id: manylinux_x86_64 |
| 58 | + - os: ubuntu-latest |
| 59 | + python: 313t |
| 60 | + platform_id: manylinux_x86_64 |
| 61 | + free_threaded_support: True |
| 62 | + |
| 63 | + # MacOS x86_64 |
| 64 | + - os: macos-13 |
| 65 | + python: 39 |
| 66 | + platform_id: macosx_x86_64 |
| 67 | + - os: macos-13 |
| 68 | + python: 310 |
| 69 | + platform_id: macosx_x86_64 |
| 70 | + - os: macos-13 |
| 71 | + python: 311 |
| 72 | + platform_id: macosx_x86_64 |
| 73 | + - os: macos-13 |
| 74 | + python: 312 |
| 75 | + platform_id: macosx_x86_64 |
| 76 | + - os: macos-13 |
| 77 | + python: 313 |
| 78 | + platform_id: macosx_x86_64 |
| 79 | + - os: macos-13 |
| 80 | + python: 313t |
| 81 | + platform_id: macosx_x86_64 |
| 82 | + free_threaded_support: True |
| 83 | + |
| 84 | + # MacOS arm64 |
| 85 | + - os: macos-14 |
| 86 | + python: 39 |
| 87 | + platform_id: macosx_arm64 |
| 88 | + - os: macos-14 |
| 89 | + python: 310 |
| 90 | + platform_id: macosx_arm64 |
| 91 | + - os: macos-14 |
| 92 | + python: 311 |
| 93 | + platform_id: macosx_arm64 |
| 94 | + - os: macos-14 |
| 95 | + python: 312 |
| 96 | + platform_id: macosx_arm64 |
| 97 | + - os: macos-14 |
| 98 | + python: 313 |
| 99 | + platform_id: macosx_arm64 |
| 100 | + - os: macos-14 |
| 101 | + python: 313t |
| 102 | + platform_id: macosx_arm64 |
| 103 | + free_threaded_support: True |
| 104 | + |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + |
| 108 | + - name: Build wheels |
| 109 | + env: |
| 110 | + CIBW_FREE_THREADED_SUPPORT: ${{ matrix.free_threaded_support }} |
| 111 | + CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} |
| 112 | + CIBW_TEST_REQUIRES: pytest psutil |
| 113 | + CIBW_TEST_COMMAND: pytest {package}/test |
| 114 | + USE_CYTHON: 1 |
| 115 | + |
| 116 | + |
| 117 | + - uses: actions/upload-artifact@v4 |
| 118 | + with: |
| 119 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 120 | + path: ./wheelhouse/*.whl |
| 121 | + |
| 122 | + build_sdist: |
| 123 | + name: Build source distribution |
| 124 | + runs-on: ubuntu-latest |
| 125 | + steps: |
| 126 | + - uses: actions/checkout@v4 |
| 127 | + |
| 128 | + - name: Build sdist |
| 129 | + run: pipx run build --sdist |
| 130 | + |
| 131 | + - uses: actions/upload-artifact@v4 |
| 132 | + with: |
| 133 | + name: cibw-sdist |
| 134 | + path: dist/*.tar.gz |
| 135 | + |
| 136 | + upload_pypi: |
| 137 | + needs: [build_wheels, build_sdist] |
| 138 | + runs-on: ubuntu-latest |
| 139 | + environment: pypi |
| 140 | + permissions: |
| 141 | + id-token: write |
| 142 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 143 | + steps: |
| 144 | + - uses: actions/download-artifact@v4 |
| 145 | + with: |
| 146 | + # unpacks all CIBW artifacts into dist/ |
| 147 | + pattern: cibw-* |
| 148 | + path: dist |
| 149 | + merge-multiple: true |
| 150 | + |
| 151 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 152 | + with: |
| 153 | + repository-url: https://test.pypi.org/legacy/ |
0 commit comments