|
| 1 | +name: Build wheels |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: ["master", "emscripten"] |
| 7 | + tags: ["v*"] |
| 8 | + |
| 9 | +jobs: |
| 10 | + native-wheels: |
| 11 | + name: Native wheels (${{ matrix.os }}) |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + os: [ubuntu-latest, windows-latest, macos-14] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: "3.12" |
| 24 | + |
| 25 | + - name: Install build tooling |
| 26 | + run: python -m pip install --upgrade pip cibuildwheel |
| 27 | + |
| 28 | + - name: Build wheels |
| 29 | + run: python -m cibuildwheel --output-dir dist |
| 30 | + env: |
| 31 | + CIBW_BUILD: cp312-* |
| 32 | + CIBW_SKIP: pp* *-musllinux_* |
| 33 | + CIBW_ARCHS_MACOS: arm64 |
| 34 | + CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=26.0 |
| 35 | + |
| 36 | + - name: Upload native wheel artifacts |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: wheels-${{ matrix.os }} |
| 40 | + path: dist/*.whl |
| 41 | + |
| 42 | + wasm-wheel: |
| 43 | + name: WASM wheel (Pyodide) |
| 44 | + runs-on: ubuntu-latest |
| 45 | + env: |
| 46 | + PYODIDE_EMSCRIPTEN_TAG: emscripten_3_1_58_wasm32 |
| 47 | + |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - uses: actions/setup-python@v5 |
| 52 | + with: |
| 53 | + python-version: "3.12" |
| 54 | + |
| 55 | + - name: Install build tooling |
| 56 | + run: python -m pip install --upgrade pip build wheel |
| 57 | + |
| 58 | + - name: Build wasm wheel |
| 59 | + run: python -m build --wheel |
| 60 | + env: |
| 61 | + PHREEQPYTHON_TARGET: wasm |
| 62 | + |
| 63 | + - name: Retag wheel for Pyodide |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + set -euo pipefail |
| 67 | + WHEEL_PATH=$(ls dist/*.whl) |
| 68 | + python -m wheel tags \ |
| 69 | + --python-tag cp312 \ |
| 70 | + --abi-tag cp312 \ |
| 71 | + --platform-tag "${PYODIDE_EMSCRIPTEN_TAG}" \ |
| 72 | + "${WHEEL_PATH}" |
| 73 | + rm -f "${WHEEL_PATH}" |
| 74 | +
|
| 75 | + - name: Upload wasm wheel artifact |
| 76 | + uses: actions/upload-artifact@v4 |
| 77 | + with: |
| 78 | + name: wheels-wasm |
| 79 | + path: dist/*.whl |
| 80 | + |
| 81 | + sdist: |
| 82 | + name: Source distribution |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - uses: actions/setup-python@v5 |
| 88 | + with: |
| 89 | + python-version: "3.12" |
| 90 | + |
| 91 | + - name: Install build tooling |
| 92 | + run: python -m pip install --upgrade pip build |
| 93 | + |
| 94 | + - name: Build sdist |
| 95 | + run: python -m build --sdist |
| 96 | + |
| 97 | + - name: Upload sdist artifact |
| 98 | + uses: actions/upload-artifact@v4 |
| 99 | + with: |
| 100 | + name: sdist |
| 101 | + path: dist/*.tar.gz |
| 102 | + |
| 103 | + pypi-publish: |
| 104 | + name: Publish to PyPI |
| 105 | + needs: [native-wheels, wasm-wheel, sdist] |
| 106 | + runs-on: ubuntu-latest |
| 107 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 108 | + permissions: |
| 109 | + id-token: write |
| 110 | + steps: |
| 111 | + - name: Download wheel artifacts |
| 112 | + uses: actions/download-artifact@v4 |
| 113 | + with: |
| 114 | + pattern: wheels-* |
| 115 | + path: dist |
| 116 | + merge-multiple: true |
| 117 | + |
| 118 | + - name: Download sdist artifact |
| 119 | + uses: actions/download-artifact@v4 |
| 120 | + with: |
| 121 | + name: sdist |
| 122 | + path: dist |
| 123 | + |
| 124 | + - name: Show artifacts |
| 125 | + shell: bash |
| 126 | + run: ls -la dist |
| 127 | + |
| 128 | + - name: Publish package distributions to PyPI |
| 129 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 130 | + with: |
| 131 | + packages-dir: dist |
0 commit comments