|
1 | | -name: Trigger wheel build |
| 1 | +name: Build and publish wheels |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [main, master, 'release*'] |
6 | | - tags: ['*'] |
| 5 | + branches: ['release-*'] |
| 6 | + tags: ['v*'] |
| 7 | + pull_request: |
| 8 | + branches: ['release-*'] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 13 | + cancel-in-progress: true |
7 | 14 |
|
8 | 15 | permissions: |
9 | 16 | contents: read |
10 | 17 |
|
11 | 18 | jobs: |
12 | | - build-wheels: |
13 | | - if: github.repository == 'python/mypy' |
| 19 | + generate_wheels_matrix: |
| 20 | + name: Generate wheels matrix |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + include: ${{ steps.set-matrix.outputs.include }} |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - name: Install cibuildwheel and pypyp |
| 27 | + run: | |
| 28 | + pipx install cibuildwheel==3.3.1 |
| 29 | + pipx install pypyp==1.3.0 |
| 30 | + - id: set-matrix |
| 31 | + run: | |
| 32 | + MATRIX=$( |
| 33 | + { |
| 34 | + cibuildwheel --print-build-identifiers --platform linux --archs x86_64 \ |
| 35 | + | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \ |
| 36 | + && cibuildwheel --print-build-identifiers --platform linux --archs aarch64 \ |
| 37 | + | pyp 'json.dumps({"only": x, "os": "ubuntu-24.04-arm"})' \ |
| 38 | + && cibuildwheel --print-build-identifiers --platform macos \ |
| 39 | + | pyp 'json.dumps({"only": x, "os": "macos-latest"})' \ |
| 40 | + && cibuildwheel --print-build-identifiers --platform windows \ |
| 41 | + | pyp 'json.dumps({"only": x, "os": "windows-latest"})' \ |
| 42 | + && cibuildwheel --print-build-identifiers --platform windows --archs ARM64 \ |
| 43 | + | pyp 'json.dumps({"only": x, "os": "windows-11-arm"})' |
| 44 | + } | pyp 'json.dumps(list(map(json.loads, lines)))' |
| 45 | + ) |
| 46 | + echo "include=$MATRIX" | tee -a $GITHUB_OUTPUT |
| 47 | + env: |
| 48 | + CIBW_ARCHS_MACOS: x86_64 arm64 |
| 49 | + |
| 50 | + build_wheels: |
| 51 | + name: Build ${{ matrix.only }} |
| 52 | + needs: generate_wheels_matrix |
| 53 | + runs-on: ${{ matrix.os }} |
| 54 | + strategy: |
| 55 | + fail-fast: false |
| 56 | + matrix: |
| 57 | + include: ${{ fromJson(needs.generate_wheels_matrix.outputs.include) }} |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + with: |
| 61 | + submodules: recursive |
| 62 | + - uses: pypa/cibuildwheel@v3.3.1 |
| 63 | + with: |
| 64 | + only: ${{ matrix.only }} |
| 65 | + - uses: actions/upload-artifact@v4 |
| 66 | + with: |
| 67 | + name: dist-${{ matrix.only }} |
| 68 | + path: ./wheelhouse/*.whl |
| 69 | + overwrite: true |
| 70 | + |
| 71 | + build_sdist: |
| 72 | + name: Build sdist and pure Python wheel |
14 | 73 | runs-on: ubuntu-latest |
15 | 74 | steps: |
16 | 75 | - uses: actions/checkout@v4 |
17 | 76 | with: |
18 | | - persist-credentials: false |
| 77 | + submodules: recursive |
19 | 78 | - uses: actions/setup-python@v5 |
20 | 79 | with: |
21 | | - python-version: '3.11' |
22 | | - - name: Trigger script |
23 | | - env: |
24 | | - WHEELS_PUSH_TOKEN: ${{ secrets.WHEELS_PUSH_TOKEN }} |
25 | | - run: ./misc/trigger_wheel_build.sh |
| 80 | + python-version: "3.13" |
| 81 | + - name: Build sdist and wheel |
| 82 | + run: | |
| 83 | + pip install --upgrade setuptools build |
| 84 | + python -m build |
| 85 | + - uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: dist-sdist |
| 88 | + path: | |
| 89 | + dist/*.whl |
| 90 | + dist/*.tar.gz |
| 91 | + overwrite: true |
| 92 | + |
| 93 | + publish: |
| 94 | + name: Publish to PyPI |
| 95 | + if: startsWith(github.ref, 'refs/tags/v') |
| 96 | + needs: [build_wheels, build_sdist] |
| 97 | + runs-on: ubuntu-latest |
| 98 | + environment: pypi |
| 99 | + permissions: |
| 100 | + id-token: write |
| 101 | + steps: |
| 102 | + - name: Download all artifacts |
| 103 | + uses: actions/download-artifact@v4 |
| 104 | + with: |
| 105 | + pattern: dist-* |
| 106 | + path: dist |
| 107 | + merge-multiple: true |
| 108 | + - name: Publish to PyPI |
| 109 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments