| 1 |
name: Build sdist and Wheels |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: [main] |
| 5 |
release: |
| 6 |
types: |
| 7 |
- published |
| 8 |
workflow_dispatch: |
| 9 |
|
| 10 |
jobs: |
| 11 |
build_wheels: |
| 12 |
strategy: |
| 13 |
matrix: |
| 14 |
include: |
| 15 |
- os: ubuntu-24.04 |
| 16 |
- os: ubuntu-24.04-arm |
| 17 |
- os: windows-latest |
| 18 |
- os: windows-11-arm |
| 19 |
- os: macos-15-intel |
| 20 |
- os: macos-latest |
| 21 |
- os: ubuntu-24.04 |
| 22 |
cibw_archs: riscv64 |
| 23 |
name_suffix: "-riscv64" |
| 24 |
|
| 25 |
runs-on: ${{ matrix.os }} |
| 26 |
name: Build wheels on ${{ matrix.os }}${{ matrix.name_suffix || '' }} |
| 27 |
|
| 28 |
steps: |
| 29 |
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 30 |
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 31 |
with: |
| 32 |
python-version: "3.x" |
| 33 |
cache: "pip" |
| 34 |
- name: Cythonize |
| 35 |
shell: bash |
| 36 |
run: | |
| 37 |
pip install -r requirements.txt |
| 38 |
make cython |
| 39 |
|
| 40 |
- name: Set up QEMU for emulation |
| 41 |
if: matrix.cibw_archs == 'riscv64' |
| 42 |
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0 |
| 43 |
with: |
| 44 |
platforms: ${{ matrix.cibw_archs }} |
| 45 |
|
| 46 |
- name: Build |
| 47 |
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0 |
| 48 |
env: |
| 49 |
CIBW_TEST_REQUIRES: "pytest" |
| 50 |
CIBW_TEST_COMMAND: "pytest {package}/test" |
| 51 |
CIBW_SKIP: "cp38-* cp39-* cp310-win_arm64" |
| 52 |
CIBW_ARCHS: ${{ matrix.cibw_archs || 'auto' }} |
| 53 |
|
| 54 |
- name: Build sdist |
| 55 |
if: runner.os == 'Linux' && runner.arch == 'X64' |
| 56 |
run: | |
| 57 |
pip install build |
| 58 |
python -m build -s -o wheelhouse |
| 59 |
|
| 60 |
- name: Upload Wheels to artifact |
| 61 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 62 |
with: |
| 63 |
name: wheels-${{ matrix.os }}${{ matrix.name_suffix || '' }} |
| 64 |
path: wheelhouse |
| 65 |
|
| 66 |
# combine all wheels into one artifact |
| 67 |
combine_wheels: |
| 68 |
needs: [build_wheels] |
| 69 |
runs-on: ubuntu-latest |
| 70 |
steps: |
| 71 |
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 72 |
with: |
| 73 |
# unpacks all CIBW artifacts into dist/ |
| 74 |
pattern: wheels-* |
| 75 |
path: dist |
| 76 |
merge-multiple: true |
| 77 |
|
| 78 |
- name: Upload Wheels to artifact |
| 79 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 80 |
with: |
| 81 |
name: wheels-all |
| 82 |
path: dist |
| 83 |
|
| 84 |
# https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml |
| 85 |
upload_pypi: |
| 86 |
needs: [build_wheels] |
| 87 |
runs-on: ubuntu-latest |
| 88 |
environment: pypi |
| 89 |
permissions: |
| 90 |
id-token: write |
| 91 |
if: github.event_name == 'release' && github.event.action == 'published' |
| 92 |
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) |
| 93 |
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 94 |
steps: |
| 95 |
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 96 |
with: |
| 97 |
# unpacks all CIBW artifacts into dist/ |
| 98 |
pattern: wheels-* |
| 99 |
path: dist |
| 100 |
merge-multiple: true |
| 101 |
|
| 102 |
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
| 103 |
#with: |
| 104 |
# To test: repository-url: https://test.pypi.org/legacy/ |