1- name : pypi
1+ name : Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
22
3- on :
4- workflow_dispatch :
5- push :
6- tags :
7- - " *"
3+ on : push
84
95jobs :
10- build_linux_wheels :
11- name : Build ${{ matrix.linux_tag }} wheels with cp${{ matrix.python-version }}
6+ build :
7+ name : Build distribution 📦
128 runs-on : ubuntu-latest
13- strategy :
14- matrix :
15- linux_tag : ["manylinux", "musllinux"]
16- python-version : ["310", "311", "312", "313"]
17- steps :
18- - uses : actions/checkout@v4
19- - name : Set up QEMU
20- uses : docker/setup-qemu-action@v3
21- with :
22- platforms : all
23- - name : Build wheels
24- 25- timeout-minutes : 720
26- env :
27- CIBW_BUILD : " cp${{ matrix.python-version }}-${{ matrix.linux_tag }}_*"
28- CIBW_ARCHS_LINUX : " x86_64 i686 aarch64"
29- CIBW_SKIP : " *-musllinux_i686"
30- CIBW_MANYLINUX_X86_64_IMAGE : " manylinux2014"
31- CIBW_MANYLINUX_I686_IMAGE : " manylinux2014"
32- CIBW_MANYLINUX_AARCH64_IMAGE : " manylinux2014"
33- CIBW_MUSLLINUX_X86_64_IMAGE : " musllinux_1_1"
34- CIBW_MUSLLINUX_I686_IMAGE : " musllinux_1_1"
35- CIBW_MUSLLINUX_AARCH64_IMAGE : " musllinux_1_1"
36- CIBW_ENVIRONMENT : ' PATH="$HOME/.cargo/bin:$PATH"'
37- CIBW_ENVIRONMENT_LINUX : ' PATH="$HOME/.cargo/bin:$PATH" CARGO_NET_GIT_FETCH_WITH_CLI="true"'
38- CIBW_BEFORE_BUILD : >
39- rustup default nightly &&
40- rustup show
41- CIBW_BEFORE_BUILD_LINUX : >
42- curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y &&
43- rustup show
44- - uses : actions/upload-artifact@v4
45- with :
46- name : artifact-${{ matrix.linux_tag }}-cp${{ matrix.python-version }}
47- path : ./wheelhouse/*.whl
48-
49- build_macos_wheels :
50- name : Build wheels on ${{ matrix.os }}
51- runs-on : ${{ matrix.os }}
52- strategy :
53- matrix :
54- os : [macos-13, macos-14]
55- steps :
56- - uses : actions/checkout@v4
57- - name : Set up rust
58- uses : dtolnay/rust-toolchain@stable
59- with :
60- toolchain : nightly
61- - run : rustup target add aarch64-apple-darwin && rustup target add x86_64-apple-darwin
62- - name : Build wheels
63- 64- timeout-minutes : 720
65- env :
66- CIBW_BUILD : " cp310-* cp311-* cp312-* cp313-*"
67- CIBW_ARCHS_MACOS : " universal2"
68- # arm64 and universal2 wheels are tagged with x86_64 because there's an issue with Poetry
69- # More information here: https://cibuildwheel.readthedocs.io/en/stable/faq/#how-to-cross-compile (CTRL + F "poetry")
70- # https://github.com/pypa/cibuildwheel/issues/1415
71- CIBW_REPAIR_WHEEL_COMMAND_MACOS : >
72- ls {dest_dir} &&
73- delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} &&
74- for file in {dest_dir}/*.whl ; do mv $file ${file//x86_64/universal2} ; done
75- CIBW_ENVIRONMENT : ' PATH="$HOME/.cargo/bin:$PATH"'
76- CIBW_BEFORE_BUILD : >
77- rustup default nightly &&
78- rustup show
79- - uses : actions/upload-artifact@v4
80- with :
81- name : artifact-${{ matrix.os }}
82- path : ./wheelhouse/*.whl
839
84- build_windows_wheels :
85- name : Build wheels on ${{ matrix.os }}
86- runs-on : ${{ matrix.os }}
87- strategy :
88- matrix :
89- os : [windows-2019, windows-2022]
9010 steps :
91- - uses : actions/checkout@v4
92- - name : Set up rust
93- uses : dtolnay/rust-toolchain@stable
94- with :
95- toolchain : nightly
96- - run : rustup toolchain install stable-i686-pc-windows-msvc
97- - run : rustup target add i686-pc-windows-msvc
98- - name : Build wheels
99- 100- timeout-minutes : 720
101- env :
102- CIBW_BUILD : " cp310-* cp311-* cp312-* cp313-*"
103- CIBW_ARCHS_WINDOWS : " AMD64 x86"
104- CIBW_ENVIRONMENT : ' PATH="$HOME/.cargo/bin:$PATH"'
105- CIBW_ENVIRONMENT_WINDOWS : ' PATH="$UserProfile\.cargo\bin;$PATH"'
106- CIBW_BEFORE_BUILD : >
107- rustup default nightly &&
108- rustup show
109- - uses : actions/upload-artifact@v4
110- with :
111- name : artifact-${{ matrix.os }}
112- path : ./wheelhouse/*.whl
11+ - uses : actions/checkout@v4
12+ with :
13+ persist-credentials : false
14+ - name : Set up Python
15+ uses : actions/setup-python@v5
16+ with :
17+ python-version : " 3.x"
18+ - name : Install pypa/build
19+ run : >-
20+ python3 -m
21+ pip install
22+ build
23+ --user
24+ - name : Build a binary wheel and a source tarball
25+ run : python3 -m build
26+ - name : Store the distribution packages
27+ uses : actions/upload-artifact@v4
28+ with :
29+ name : python-package-distributions
30+ path : dist/
11331
114- build_sdist :
115- name : Build source distribution
116- # Can't use more than 12 jobs in parallel
117- needs : [build_macos_wheels]
32+ publish-to-pypi :
33+ name : >-
34+ Publish Python 🐍 distribution 📦 to PyPI
35+ if : startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
36+ needs :
37+ - build
11838 runs-on : ubuntu-latest
119- steps :
120- - uses : actions/checkout@v4
39+ environment :
40+ name : pypi
41+ url : https://pypi.org/p/pyikt # Replace pyikt with your PyPI project name
42+ permissions :
43+ id-token : write # IMPORTANT: mandatory for trusted publishing
12144
122- - name : Build River
123- uses : ./.github/actions/install-env
124- with :
125- python-version : " 3.13"
45+ steps :
46+ - name : Download all the dists
47+ uses : actions/download-artifact@v4
48+ with :
49+ name : python-package-distributions
50+ path : dist/
51+ - name : Publish distribution 📦 to PyPI
52+ uses : pypa/gh-action-pypi-publish@release/v1
12653
127- - name : Build dist
128- run : poetry build
54+ github-release :
55+ name : >-
56+ Sign the Python 🐍 distribution 📦 with Sigstore
57+ and upload them to GitHub Release
58+ needs :
59+ - publish-to-pypi
60+ runs-on : ubuntu-latest
12961
130- - uses : actions/upload-artifact@v4
131- with :
132- name : artifact-sdist
133- path : dist/*.tar.gz
62+ permissions :
63+ contents : write # IMPORTANT: mandatory for making GitHub Releases
64+ id-token : write # IMPORTANT: mandatory for sigstore
13465
135- merge_artifacts :
136- runs-on : ubuntu-latest
137- needs : [build_linux_wheels, build_macos_wheels, build_windows_wheels, build_sdist]
13866 steps :
139- - name : Merge Artifacts
140- uses : actions/upload-artifact/merge@v4
141- with :
142- name : artifact
143- pattern : artifact-*
67+ - name : Download all the dists
68+ uses : actions/download-artifact@v4
69+ with :
70+ name : python-package-distributions
71+ path : dist/
72+ - name : Sign the dists with Sigstore
73+ 74+ with :
75+ inputs : >-
76+ ./dist/*.tar.gz
77+ ./dist/*.whl
78+ - name : Create GitHub Release
79+ env :
80+ GITHUB_TOKEN : ${{ github.token }}
81+ run : >-
82+ gh release create
83+ "$GITHUB_REF_NAME"
84+ --repo "$GITHUB_REPOSITORY"
85+ --notes ""
86+ - name : Upload artifact signatures to GitHub Release
87+ env :
88+ GITHUB_TOKEN : ${{ github.token }}
89+ # Upload to GitHub Release using the `gh` CLI.
90+ # `dist/` contains the built packages, and the
91+ # sigstore-produced signatures and certificates.
92+ run : >-
93+ gh release upload
94+ "$GITHUB_REF_NAME" dist/**
95+ --repo "$GITHUB_REPOSITORY"
14496
145- upload_pypi :
146- needs : merge_artifacts
97+ publish-to-testpypi :
98+ name : Publish Python 🐍 distribution 📦 to TestPyPI
99+ needs :
100+ - build
147101 runs-on : ubuntu-latest
148- steps :
149- 150- with :
151- name : artifact
152- path : dist
153102
154- 155- with :
156- user : __token__
157- password : ${{ secrets.PYPI_API_TOKEN }}
103+ environment :
104+ name : testpypi
105+ url : https://test.pypi.org/p/pyikt
106+
107+ permissions :
108+ id-token : write # IMPORTANT: mandatory for trusted publishing
109+
110+ steps :
111+ - name : Download all the dists
112+ uses : actions/download-artifact@v4
113+ with :
114+ name : python-package-distributions
115+ path : dist/
116+ - name : Publish distribution 📦 to TestPyPI
117+ uses : pypa/gh-action-pypi-publish@release/v1
118+ with :
119+ repository-url : https://test.pypi.org/legacy/
0 commit comments