| 1 |
# Build Python sdist and wheel. |
| 2 |
name: build_wheels |
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
push: |
| 6 |
release: |
| 7 |
types: [published] |
| 8 |
# Allow trigger via API |
| 9 |
workflow_dispatch: |
| 10 |
permissions: read-all |
| 11 |
jobs: |
| 12 |
build_sdist: |
| 13 |
name: Build sdist |
| 14 |
runs-on: ubuntu-latest |
| 15 |
steps: |
| 16 |
- uses: actions/checkout@v6 |
| 17 |
- name: Install build dependencies |
| 18 |
run: | |
| 19 |
sudo apt update |
| 20 |
sudo apt -y install python3-build |
| 21 |
- name: Build sdist |
| 22 |
run: | |
| 23 |
python -m build --sdist |
| 24 |
- uses: actions/upload-artifact@v7 |
| 25 |
with: |
| 26 |
name: cibw-sdist |
| 27 |
path: dist/*.tar.gz |
| 28 |
build_wheel: |
| 29 |
name: Build wheel |
| 30 |
runs-on: ubuntu-latest |
| 31 |
steps: |
| 32 |
- uses: actions/checkout@v6 |
| 33 |
- name: Install build dependencies |
| 34 |
run: | |
| 35 |
sudo apt update |
| 36 |
sudo apt -y install python3-build python3-wheel |
| 37 |
- name: Build wheel |
| 38 |
run: | |
| 39 |
python -m build --wheel |
| 40 |
- uses: actions/upload-artifact@v7 |
| 41 |
with: |
| 42 |
name: cibw-wheels |
| 43 |
path: dist/*.whl |
| 44 |
upload_test_pypi: |
| 45 |
needs: [build_sdist, build_wheel] |
| 46 |
runs-on: ubuntu-latest |
| 47 |
environment: pypi |
| 48 |
permissions: |
| 49 |
id-token: write |
| 50 |
if: github.event_name == 'release' && github.event.action == 'published' |
| 51 |
steps: |
| 52 |
- uses: actions/download-artifact@v8 |
| 53 |
with: |
| 54 |
pattern: cibw-* |
| 55 |
path: dist |
| 56 |
merge-multiple: true |
| 57 |
- uses: pypa/gh-action-pypi-publish@release/v1 |
| 58 |
with: |
| 59 |
repository-url: https://test.pypi.org/legacy/ |
| 60 |
upload_pypi: |
| 61 |
needs: [upload_test_pypi] |
| 62 |
runs-on: ubuntu-latest |
| 63 |
environment: pypi |
| 64 |
permissions: |
| 65 |
id-token: write |
| 66 |
if: github.event_name == 'release' && github.event.action == 'published' |
| 67 |
steps: |
| 68 |
- uses: actions/download-artifact@v8 |
| 69 |
with: |
| 70 |
pattern: cibw-* |
| 71 |
path: dist |
| 72 |
merge-multiple: true |
| 73 |
- uses: pypa/gh-action-pypi-publish@release/v1 |