1+ name : Release
2+
3+ on :
4+ release :
5+ types : [published]
6+ push :
7+ tags :
8+ - ' v*'
9+
10+ env :
11+ PYTHON_VERSION : ' 3.11'
12+
13+ jobs :
14+ build-sdist :
15+ name : Build source distribution
16+ runs-on : ubuntu-latest
17+ steps :
18+ - uses : actions/checkout@v4
19+
20+ - name : Set up Python
21+ uses : actions/setup-python@v5
22+ with :
23+ python-version : ${{ env.PYTHON_VERSION }}
24+
25+ - name : Install build dependencies
26+ run : |
27+ python -m pip install --upgrade pip
28+ pip install build setuptools wheel pybind11
29+
30+ - name : Build sdist
31+ run : python -m build --sdist
32+
33+ - name : Upload sdist
34+ uses : actions/upload-artifact@v4
35+ with :
36+ name : dist-sdist
37+ path : dist/*.tar.gz
38+
39+ build-wheels :
40+ name : Build wheels on ${{ matrix.os }}
41+ runs-on : ${{ matrix.os }}
42+ strategy :
43+ matrix :
44+ os : [ubuntu-20.04, windows-2019, macos-11]
45+
46+ steps :
47+ - uses : actions/checkout@v4
48+
49+ - name : Set up Python
50+ uses : actions/setup-python@v5
51+ with :
52+ python-version : ${{ env.PYTHON_VERSION }}
53+
54+ - name : Install build dependencies
55+ run : |
56+ python -m pip install --upgrade pip
57+ pip install build setuptools wheel pybind11 cibuildwheel==2.16.2
58+
59+ - name : Build wheels
60+ run : python -m cibuildwheel --output-dir wheelhouse
61+ env :
62+ CIBW_ARCHS_MACOS : x86_64 arm64
63+ CIBW_ARCHS_LINUX : x86_64
64+ CIBW_ARCHS_WINDOWS : AMD64
65+
66+ - name : Upload wheels
67+ uses : actions/upload-artifact@v4
68+ with :
69+ name : dist-${{ matrix.os }}
70+ path : wheelhouse/*.whl
71+
72+ upload-release :
73+ name : Upload to release
74+ needs : [build-sdist, build-wheels]
75+ runs-on : ubuntu-latest
76+ if : github.event_name == 'release' && github.event.action == 'published'
77+ permissions :
78+ contents : write
79+ steps :
80+ - name : Download all distributions
81+ uses : actions/download-artifact@v4
82+ with :
83+ pattern : dist-*
84+ merge-multiple : true
85+ path : dist/
86+
87+ - name : Upload to GitHub Release
88+ uses : softprops/action-gh-release@v2
89+ with :
90+ files : dist/*
91+ prerelease : ${{ github.event.release.prerelease }}
92+
93+ publish-pypi :
94+ name : Publish to PyPI
95+ needs : [build-sdist, build-wheels]
96+ runs-on : ubuntu-latest
97+ if : github.event_name == 'release' && github.event.action == 'published' && !github.event.release.prerelease
98+ environment : release
99+ permissions :
100+ id-token : write
101+ steps :
102+ - name : Download all distributions
103+ uses : actions/download-artifact@v4
104+ with :
105+ pattern : dist-*
106+ merge-multiple : true
107+ path : dist/
108+
109+ - name : Publish to PyPI
110+ uses : pypa/gh-action-pypi-publish@release/v1
111+ with :
112+ packages-dir : dist/
0 commit comments