|
| 1 | +name: Build and Publish Wheels |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + types: [published] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_wheels: |
| 11 | + name: Build wheels using cibuildwheel |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + # ---------------------------------------------------- |
| 18 | + # manylinux 64-bit |
| 19 | + # ---------------------------------------------------- |
| 20 | + - os: ubuntu-latest |
| 21 | + build_type: manylinux-x64 |
| 22 | + cibw_build: "*manylinux*" |
| 23 | + cibw_archs_linux: x86_64 |
| 24 | + artifact_name: "wheels-ubuntu-latest-manylinux-x64" |
| 25 | + |
| 26 | + # ---------------------------------------------------- |
| 27 | + # manylinux 32-bit |
| 28 | + # ---------------------------------------------------- |
| 29 | + - os: ubuntu-latest |
| 30 | + build_type: manylinux-x86 |
| 31 | + cibw_build: "*manylinux*" |
| 32 | + cibw_archs_linux: i686 |
| 33 | + artifact_name: "wheels-ubuntu-latest-manylinux-x86" |
| 34 | + |
| 35 | + # ---------------------------------------------------- |
| 36 | + # musllinux 64-bit |
| 37 | + # ---------------------------------------------------- |
| 38 | + - os: ubuntu-latest |
| 39 | + build_type: musllinux-x64 |
| 40 | + cibw_build: "*musllinux*" |
| 41 | + cibw_archs_linux: x86_64 |
| 42 | + artifact_name: "wheels-ubuntu-latest-musllinux-x64" |
| 43 | + |
| 44 | + # ---------------------------------------------------- |
| 45 | + # musllinux 32-bit |
| 46 | + # ---------------------------------------------------- |
| 47 | + - os: ubuntu-latest |
| 48 | + build_type: musllinux-x86 |
| 49 | + cibw_build: "*musllinux*" |
| 50 | + cibw_archs_linux: i686 |
| 51 | + artifact_name: "wheels-ubuntu-latest-musllinux-x86" |
| 52 | + |
| 53 | + # ---------------------------------------------------- |
| 54 | + # macOS (64-bit only) |
| 55 | + # ---------------------------------------------------- |
| 56 | + - os: macos-latest |
| 57 | + build_type: macos |
| 58 | + cibw_build: "" |
| 59 | + cibw_archs_linux: "" |
| 60 | + artifact_name: "wheels-macos-latest" |
| 61 | + |
| 62 | + # ---------------------------------------------------- |
| 63 | + # Windows 64-bit |
| 64 | + # ---------------------------------------------------- |
| 65 | + - os: windows-latest |
| 66 | + build_type: winx64 |
| 67 | + cibw_build: "" |
| 68 | + cibw_archs_windows: AMD64 |
| 69 | + artifact_name: "wheels-windows-latest-x64" |
| 70 | + |
| 71 | + # ---------------------------------------------------- |
| 72 | + # Windows 32-bit |
| 73 | + # ---------------------------------------------------- |
| 74 | + - os: windows-latest |
| 75 | + build_type: winx86 |
| 76 | + cibw_build: "" |
| 77 | + cibw_archs_windows: x86 |
| 78 | + artifact_name: "wheels-windows-latest-x86" |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Check out code |
| 82 | + uses: actions/checkout@v3 |
| 83 | + with: |
| 84 | + fetch-depth: 0 |
| 85 | + |
| 86 | + - name: Set up Python |
| 87 | + uses: actions/setup-python@v4 |
| 88 | + with: |
| 89 | + python-version: "3.11" |
| 90 | + |
| 91 | + - name: Install cibuildwheel |
| 92 | + run: | |
| 93 | + python -m pip install --upgrade pip setuptools wheel cibuildwheel |
| 94 | +
|
| 95 | + - name: Build wheels |
| 96 | + env: |
| 97 | + # Skip PyPy |
| 98 | + CIBW_SKIP: pp* |
| 99 | + # On Linux: manylinux / musllinux arches |
| 100 | + CIBW_ARCHS_LINUX: ${{ matrix.cibw_archs_linux || '' }} |
| 101 | + # On Windows: AMD64 / x86 |
| 102 | + CIBW_ARCHS_WINDOWS: ${{ matrix.cibw_archs_windows || '' }} |
| 103 | + # Which wheels to build for Linux (manylinux vs. musllinux) |
| 104 | + CIBW_BUILD: ${{ matrix.cibw_build || '' }} |
| 105 | + run: | |
| 106 | + python -m cibuildwheel --output-dir wheelhouse |
| 107 | +
|
| 108 | + - name: Upload wheels |
| 109 | + uses: actions/upload-artifact@v4 |
| 110 | + with: |
| 111 | + name: ${{ matrix.artifact_name }} |
| 112 | + path: wheelhouse/*.whl |
| 113 | + |
| 114 | + publish_sdist_and_wheels: |
| 115 | + name: Publish wheels to PyPI |
| 116 | + needs: build_wheels |
| 117 | + runs-on: ubuntu-latest |
| 118 | + steps: |
| 119 | + - name: Check out code |
| 120 | + uses: actions/checkout@v3 |
| 121 | + with: |
| 122 | + fetch-depth: 0 |
| 123 | + |
| 124 | + - name: Set up Python |
| 125 | + uses: actions/setup-python@v4 |
| 126 | + with: |
| 127 | + python-version: "3.11" |
| 128 | + |
| 129 | + - name: Install dependencies |
| 130 | + run: | |
| 131 | + python -m pip install --upgrade pip |
| 132 | + pip install setuptools wheel twine |
| 133 | +
|
| 134 | + - name: Build sdist |
| 135 | + run: | |
| 136 | + python setup.py sdist |
| 137 | +
|
| 138 | + # ---------------------------------------------------- |
| 139 | + # Download wheels built on each runner |
| 140 | + # ---------------------------------------------------- |
| 141 | + - name: Download manylinux 64-bit wheels |
| 142 | + uses: actions/download-artifact@v4 |
| 143 | + with: |
| 144 | + name: "wheels-ubuntu-latest-manylinux-x64" |
| 145 | + path: wheelhouse/linux-many-x64 |
| 146 | + |
| 147 | + - name: Download manylinux 32-bit wheels |
| 148 | + uses: actions/download-artifact@v4 |
| 149 | + with: |
| 150 | + name: "wheels-ubuntu-latest-manylinux-x86" |
| 151 | + path: wheelhouse/linux-many-x86 |
| 152 | + |
| 153 | + - name: Download musllinux 64-bit wheels |
| 154 | + uses: actions/download-artifact@v4 |
| 155 | + with: |
| 156 | + name: "wheels-ubuntu-latest-musllinux-x64" |
| 157 | + path: wheelhouse/linux-musl-x64 |
| 158 | + |
| 159 | + - name: Download musllinux 32-bit wheels |
| 160 | + uses: actions/download-artifact@v4 |
| 161 | + with: |
| 162 | + name: "wheels-ubuntu-latest-musllinux-x86" |
| 163 | + path: wheelhouse/linux-musl-x86 |
| 164 | + |
| 165 | + - name: Download macOS wheels |
| 166 | + uses: actions/download-artifact@v4 |
| 167 | + with: |
| 168 | + name: "wheels-macos-latest" |
| 169 | + path: wheelhouse/macos |
| 170 | + |
| 171 | + - name: Download Windows 64-bit wheels |
| 172 | + uses: actions/download-artifact@v4 |
| 173 | + with: |
| 174 | + name: "wheels-windows-latest-x64" |
| 175 | + path: wheelhouse/windows-x64 |
| 176 | + |
| 177 | + - name: Download Windows 32-bit wheels |
| 178 | + uses: actions/download-artifact@v4 |
| 179 | + with: |
| 180 | + name: "wheels-windows-latest-x86" |
| 181 | + path: wheelhouse/windows-x86 |
| 182 | + |
| 183 | + # ---------------------------------------------------- |
| 184 | + # Publish all built artifacts to PyPI |
| 185 | + # ---------------------------------------------------- |
| 186 | + - name: Publish sdist and wheels to PyPI |
| 187 | + env: |
| 188 | + TWINE_USERNAME: __token__ |
| 189 | + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 190 | + run: | |
| 191 | + twine upload \ |
| 192 | + dist/* \ |
| 193 | + wheelhouse/linux-many-x64/*.whl \ |
| 194 | + wheelhouse/linux-many-x86/*.whl \ |
| 195 | + wheelhouse/linux-musl-x64/*.whl \ |
| 196 | + wheelhouse/linux-musl-x86/*.whl \ |
| 197 | + wheelhouse/macos/*.whl \ |
| 198 | + wheelhouse/windows-x64/*.whl \ |
| 199 | + wheelhouse/windows-x86/*.whl |
0 commit comments