1- # This workflow will upload a Python Package using Twine when a release is created
2- # For more information see: https://docs. github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
1+ # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
2+ # https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
33
4- # This workflow uses actions that are not certified by GitHub.
5- # They are provided by a third-party and are governed by
6- # separate terms of service, privacy policy, and support
7- # documentation.
8-
9- name : Upload Python Package
4+ name : Build and upload to PyPI
105
116on :
7+ workflow_dispatch :
8+ pull_request :
9+ push :
10+ branches : [main]
1211 release :
1312 types : [published]
1413
1514jobs :
16- deploy :
15+ build_wheels :
16+ name : Build wheels for ${{ matrix.os }}
17+ runs-on : ${{ matrix.runs-on }}
18+ strategy :
19+ matrix :
20+ include :
21+ - os : linux-intel
22+ runs-on : ubuntu-latest
23+ - os : linux-arm
24+ runs-on : ubuntu-24.04-arm
25+ - os : windows-intel
26+ runs-on : windows-latest
27+ - os : windows-arm
28+ runs-on : windows-11-arm
29+ - os : macos-intel
30+ # macos-13 was the last x86_64 runner
31+ runs-on : macos-13
32+ - os : macos-arm
33+ # macos-14+ (including latest) are ARM64 runners
34+ runs-on : macos-latest
35+
36+ steps :
37+ - uses : actions/checkout@v5
38+ - name : Build wheels
39+ 40+ - uses : actions/upload-artifact@v4
41+ with :
42+ name : cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
43+ path : ./wheelhouse/*.whl
1744
45+ build_sdist :
46+ name : Build source distribution
1847 runs-on : ubuntu-latest
48+ steps :
49+ - uses : actions/checkout@v5
50+ - name : Build sdist
51+ run : uvx run build --sdist
52+ - uses : actions/upload-artifact@v4
53+ with :
54+ name : cibw-sdist
55+ path : dist/*.tar.gz
1956
57+ upload_pypi :
58+ needs : [build_wheels, build_sdist]
59+ runs-on : ubuntu-latest
2060 environment : publish
21-
2261 permissions :
2362 id-token : write
24-
63+ if : github.event_name == 'release' && github.event.action == 'published'
64+ # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
65+ # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
2566 steps :
26- - uses : actions/checkout@v4
27- - name : Set up Python
28- uses : actions/setup-python@v5
29- with :
30- python-version : ' 3.x '
31- - name : Install CLI tool
32- run : pip install build
33- - name : Build package
34- run : python -m build
35- - name : Publish package
36- uses : pypa/gh-action- pypi-publish@release/v1
67+ - uses : actions/download-artifact@v5
68+ with :
69+ # unpacks all CIBW artifacts into dist/
70+ pattern : cibw-*
71+ path : dist
72+ merge-multiple : true
73+
74+ - uses : pypa/gh-action-pypi-publish@release/v1
75+ # To test uploads to TestPyPI, uncomment the following:
76+ # with:
77+ # repository-url: https://test. pypi.org/legacy/
0 commit comments