|
| 1 | +name: Publish PyKLU to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v[0-9]*.[0-9]*.[0-9]*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-wheels: |
| 10 | + name: Build wheels (${{ matrix.os }}) |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [ubuntu-latest, macos-13, macos-14] |
| 15 | + pyver: [cp39, cp310, cp311, cp312, cp313, cp314] |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Check out source (with submodules) |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + submodules: recursive |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: "3.11" |
| 28 | + |
| 29 | + - name: Install cibuildwheel |
| 30 | + run: python -m pip install --upgrade pip cibuildwheel |
| 31 | + |
| 32 | + - name: Build wheels with cibuildwheel |
| 33 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 34 | + env: |
| 35 | + # Build for these CPython versions |
| 36 | + CIBW_BUILD: ${{ matrix.pyver }}-* |
| 37 | + |
| 38 | + # Linux: run inside manylinux containers, use yum |
| 39 | + CIBW_BEFORE_BUILD_LINUX: | |
| 40 | + yum install -y openblas-devel || true |
| 41 | + python -m pip install --upgrade pip |
| 42 | + python -m pip install cmake numpy scipy |
| 43 | +
|
| 44 | + # macOS: runs directly on the macOS runner, use Homebrew |
| 45 | + CIBW_BEFORE_BUILD_MACOS: | |
| 46 | + brew install openblas || true |
| 47 | + python -m pip install --upgrade pip |
| 48 | + python -m pip install cmake numpy scipy |
| 49 | +
|
| 50 | + # Skip 32-bit & musllinux if you don’t care about them |
| 51 | + CIBW_SKIP: "cp3?-manylinux_i686 *musllinux*" |
| 52 | + |
| 53 | + - name: Upload wheel artifacts |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 57 | + path: wheelhouse/*.whl |
| 58 | + |
| 59 | + build-sdist: |
| 60 | + name: Build sdist |
| 61 | + runs-on: ubuntu-latest |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + with: |
| 66 | + submodules: recursive |
| 67 | + fetch-depth: 0 |
| 68 | + |
| 69 | + - uses: actions/setup-python@v5 |
| 70 | + with: |
| 71 | + python-version: "3.11" |
| 72 | + |
| 73 | + - name: Install build |
| 74 | + run: python -m pip install --upgrade pip build |
| 75 | + |
| 76 | + - name: Build sdist |
| 77 | + run: python -m build --sdist |
| 78 | + |
| 79 | + - name: Upload sdist artifact |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: sdist |
| 83 | + path: dist/*.tar.gz |
| 84 | + |
| 85 | + publish-to-pypi: |
| 86 | + name: Publish to PyPI |
| 87 | + runs-on: ubuntu-latest |
| 88 | + needs: [build-wheels, build-sdist] |
| 89 | + |
| 90 | + environment: |
| 91 | + name: pypi |
| 92 | + url: https://pypi.org/project/pyklu/ |
| 93 | + |
| 94 | + permissions: |
| 95 | + id-token: write |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Download wheels |
| 99 | + uses: actions/download-artifact@v4 |
| 100 | + with: |
| 101 | + pattern: wheels-* |
| 102 | + path: dist |
| 103 | + merge-multiple: true |
| 104 | + |
| 105 | + - name: Download sdist |
| 106 | + uses: actions/download-artifact@v4 |
| 107 | + with: |
| 108 | + name: sdist |
| 109 | + path: dist |
| 110 | + |
| 111 | + - name: Show files to be uploaded |
| 112 | + run: ls -R dist |
| 113 | + |
| 114 | + - name: Publish to PyPI |
| 115 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 116 | + with: |
| 117 | + verbose: true |
0 commit comments