|
| 1 | +name: Python package build and publish |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: {} |
| 7 | + repository_dispatch: {} |
| 8 | + pull_request: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: wheels-${{ github.event.pull_request.number || github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + build_wheels: |
| 19 | + name: ${{ matrix.image }} wheels |
| 20 | + runs-on: ubuntu-24.04 |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - image: manylinux_2_28_x86_64 |
| 25 | + build: "*manylinux*" |
| 26 | + - image: musllinux_1_1_x86_64 |
| 27 | + build: "*musllinux*" |
| 28 | + - image: musllinux_1_2_x86_64 |
| 29 | + build: "*musllinux*" |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + if: ${{ github.event_name != 'repository_dispatch' }} |
| 34 | + with: |
| 35 | + fetch-depth: 0 # slow, but gets all the tags |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + if: ${{ github.event_name == 'repository_dispatch' }} |
| 38 | + with: |
| 39 | + fetch-depth: 0 # slow, but gets all the tags |
| 40 | + ref: ${{ github.event.client_payload.ref }} |
| 41 | + |
| 42 | + # - name: Set up QEMU |
| 43 | + # if: runner.os == 'Linux' |
| 44 | + # uses: docker/setup-qemu-action@v2 |
| 45 | + # with: |
| 46 | + # platforms: all |
| 47 | + |
| 48 | + - name: Build wheels |
| 49 | + |
| 50 | + env: |
| 51 | + CIBW_BUILD: ${{ matrix.build }} |
| 52 | + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/${{ matrix.image }} |
| 53 | + CIBW_MUSLLINUX_X86_64_IMAGE: quay.io/pypa/${{ matrix.image }} |
| 54 | + # configure cibuildwheel to build native 64-bit archs ('auto64'), and some |
| 55 | + # emulated ones |
| 56 | + # Linux arm64 wheels are built on circleci |
| 57 | + CIBW_ARCHS_LINUX: auto64 # ppc64le s390x |
| 58 | + |
| 59 | + - uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: artifact-${{ matrix.image }} |
| 62 | + path: ./wheelhouse/*.whl |
| 63 | + |
| 64 | + build_sdist: |
| 65 | + name: Build source distribution |
| 66 | + runs-on: ubuntu-24.04 |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + if: ${{ github.event_name != 'repository_dispatch' }} |
| 70 | + with: |
| 71 | + fetch-depth: 0 # slow, but gets all the tags |
| 72 | + - uses: actions/checkout@v4 |
| 73 | + if: ${{ github.event_name == 'repository_dispatch' }} |
| 74 | + with: |
| 75 | + fetch-depth: 0 # slow, but gets all the tags |
| 76 | + ref: ${{ github.event.client_payload.ref }} |
| 77 | + |
| 78 | + - name: Build sdist |
| 79 | + run: pipx run build --sdist |
| 80 | + |
| 81 | + - uses: actions/upload-artifact@v4 |
| 82 | + with: |
| 83 | + name: artifact-source |
| 84 | + path: dist/*.tar.gz |
| 85 | + |
| 86 | + build_wheels_macos: |
| 87 | + name: Build wheels on ${{ matrix.os }} |
| 88 | + runs-on: ${{ matrix.os }} |
| 89 | + strategy: |
| 90 | + matrix: |
| 91 | + # macos-13 is an intel runner, macos-14 is apple silicon |
| 92 | + os: [macos-13, macos-14] |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v4 |
| 95 | + if: ${{ github.event_name != 'repository_dispatch' }} |
| 96 | + with: |
| 97 | + fetch-depth: 0 # slow, but gets all the tags |
| 98 | + - uses: actions/checkout@v4 |
| 99 | + if: ${{ github.event_name == 'repository_dispatch' }} |
| 100 | + with: |
| 101 | + fetch-depth: 0 # slow, but gets all the tags |
| 102 | + ref: ${{ github.event.client_payload.ref }} |
| 103 | + |
| 104 | + - name: Build wheels |
| 105 | + |
| 106 | + |
| 107 | + - uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: artifact-${{ matrix.os }}-${{ strategy.job-index }} |
| 110 | + path: ./wheelhouse/*.whl |
| 111 | + |
| 112 | + # upload_pypi: |
| 113 | + # needs: [build_wheels, build_sdist] |
| 114 | + # runs-on: ubuntu-24.04 |
| 115 | + # environment: deploy |
| 116 | + # permissions: |
| 117 | + # id-token: write |
| 118 | + # if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'repository_dispatch' && github.event.client_payload.publish_wheel == true) |
| 119 | + # steps: |
| 120 | + # - uses: actions/download-artifact@v4 |
| 121 | + # with: |
| 122 | + # # unpacks default artifact into dist/ |
| 123 | + # pattern: artifact-* |
| 124 | + # merge-multiple: true |
| 125 | + # path: dist |
| 126 | + |
| 127 | + # - name: Publish package distributions to PyPI |
| 128 | + # uses: pypa/gh-action-pypi-publish@release/v1 |
| 129 | + # with: |
| 130 | + # skip-existing: true |
0 commit comments