|
6 | 6 | # separate terms of service, privacy policy, and support |
7 | 7 | # documentation. |
8 | 8 |
|
9 | | -name: Upload Python Package |
| 9 | +name: Build and upload Python Package |
10 | 10 |
|
11 | 11 | on: |
| 12 | + workflow_dispatch: |
| 13 | + pull_request: |
| 14 | + push: |
| 15 | + branches: |
| 16 | + - main |
12 | 17 | release: |
13 | | - types: [published] |
| 18 | + types: |
| 19 | + - published |
14 | 20 |
|
15 | 21 | permissions: |
16 | 22 | contents: read |
17 | 23 |
|
18 | 24 | jobs: |
19 | | - build: |
20 | | - name: Build distribution |
21 | | - runs-on: ubuntu-latest |
| 25 | + build_wheels: |
| 26 | + name: Build wheels for ${{ matrix.os }} |
| 27 | + runs-on: ${{ matrix.runs-on }} |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + os: [ linux-intel, linux-arm, windows, macOS-intel, macOS-arm, iOS, pyodide ] |
| 31 | + include: |
| 32 | + - archs: auto |
| 33 | + platform: auto |
| 34 | + - os: linux-intel |
| 35 | + runs-on: ubuntu-latest |
| 36 | + - os: linux-arm |
| 37 | + runs-on: ubuntu-24.04-arm |
| 38 | + - os: windows |
| 39 | + runs-on: windows-latest |
| 40 | + - os: macos-intel |
| 41 | + # macos-13 was the last x86_64 runner |
| 42 | + runs-on: macos-13 |
| 43 | + - os: macos-arm |
| 44 | + # macos-14+ (including latest) are ARM64 runners |
| 45 | + runs-on: macos-latest |
| 46 | + archs: auto,universal2 |
22 | 47 |
|
23 | 48 | steps: |
24 | 49 | - uses: actions/checkout@v4 |
25 | | - - name: Set up Python |
26 | | - uses: actions/setup-python@v5 |
27 | | - with: |
28 | | - python-version: "3.x" |
29 | | - - name: Install pypa/build |
30 | | - run: python3 -m pip install build --user |
31 | | - - name: Build a binary wheel and a source tarball |
32 | | - run: python3 -m build |
33 | | - - name: Store the distribution packages |
34 | | - uses: actions/upload-artifact@v4 |
35 | | - with: |
36 | | - name: python-package-distributions |
37 | | - path: dist/ |
| 50 | + |
| 51 | + - name: Build wheels |
| 52 | + uses: pypa/cibuildwheel@@v2.23.3 |
| 53 | + env: |
| 54 | + CIBW_PLATFORM: ${{ matrix.platform }} |
| 55 | + CIBW_ARCHS: ${{ matrix.archs }} |
| 56 | + |
| 57 | + - uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 60 | + path: ./wheelhouse/*.whl |
| 61 | + |
| 62 | + build_sdist: |
| 63 | + name: Build source distribution |
| 64 | + runs-on: ubuntu-latest |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - name: Build sdist |
| 69 | + run: pipx run build --sdist |
| 70 | + |
| 71 | + - uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: cibw-sdist |
| 74 | + path: dist/*.tar.gz |
38 | 75 |
|
39 | 76 | publish-to-pypi: |
40 | 77 | name: Publish Python distribution to PyPI |
41 | 78 | if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
42 | 79 | needs: |
43 | | - - build |
| 80 | + - build_wheels |
| 81 | + - build_sdist |
44 | 82 | runs-on: ubuntu-latest |
45 | 83 | environment: release |
46 | 84 | permissions: |
|
49 | 87 | - name: Download the dist file |
50 | 88 | uses: actions/download-artifact@v4 |
51 | 89 | with: |
52 | | - name: python-package-distributions |
53 | | - path: dist/ |
| 90 | + pattern: cibw-* |
| 91 | + path: dist |
| 92 | + merge-multiple: true |
54 | 93 | - name: Publish distribution to PyPI |
55 | 94 | uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments