33#
44# maturin generate-ci github
55#
6- name : python-bindings-build-ci
6+ name : python-bindings
77
8- on : [pull_request]
8+ on :
9+ push :
10+ branches :
11+ - main
12+ - master
13+ tags :
14+ - ' *'
15+ pull_request :
16+ workflow_dispatch :
917
1018permissions :
1119 contents : read
@@ -29,13 +37,21 @@ jobs:
2937 - uses : actions/setup-python@v5
3038 with :
3139 python-version : 3.x
40+ - name : Generate pyo3 stub
41+ run : |
42+ cargo run --bin stub_gen --features python
3243 - name : Build wheels
3344 uses : PyO3/maturin-action@v1
3445 with :
3546 target : ${{ matrix.platform.target }}
36- args : --release --features python --out dist --find-interpreter
47+ args : --release --features python --features pyo3/extension-module -- out dist --find-interpreter
3748 sccache : ${{ !startsWith(github.ref, 'refs/tags/') }}
3849 manylinux : auto
50+ - name : Upload wheels
51+ uses : actions/upload-artifact@v4
52+ with :
53+ name : wheels-linux-${{ matrix.platform.target }}
54+ path : dist
3955
4056 musllinux :
4157 runs-on : ${{ matrix.platform.runner }}
@@ -55,13 +71,21 @@ jobs:
5571 - uses : actions/setup-python@v5
5672 with :
5773 python-version : 3.x
74+ - name : Generate pyo3 stub
75+ run : |
76+ cargo run --bin stub_gen --features python
5877 - name : Build wheels
5978 uses : PyO3/maturin-action@v1
6079 with :
6180 target : ${{ matrix.platform.target }}
62- args : --release --features python --out dist --find-interpreter
81+ args : --release --features python --features pyo3/extension-module -- out dist --find-interpreter
6382 sccache : ${{ !startsWith(github.ref, 'refs/tags/') }}
6483 manylinux : musllinux_1_2
84+ - name : Upload wheels
85+ uses : actions/upload-artifact@v4
86+ with :
87+ name : wheels-musllinux-${{ matrix.platform.target }}
88+ path : dist
6589
6690 windows :
6791 runs-on : ${{ matrix.platform.runner }}
@@ -82,8 +106,13 @@ jobs:
82106 uses : PyO3/maturin-action@v1
83107 with :
84108 target : ${{ matrix.platform.target }}
85- args : --release --features python --out dist --find-interpreter
109+ args : --release --features python --features pyo3/extension-module -- out dist --find-interpreter
86110 sccache : ${{ !startsWith(github.ref, 'refs/tags/') }}
111+ - name : Upload wheels
112+ uses : actions/upload-artifact@v4
113+ with :
114+ name : wheels-windows-${{ matrix.platform.target }}
115+ path : dist
87116
88117 macos :
89118 runs-on : ${{ matrix.platform.runner }}
@@ -99,19 +128,62 @@ jobs:
99128 - uses : actions/setup-python@v5
100129 with :
101130 python-version : 3.x
131+ - name : Generate pyo3 stub
132+ run : |
133+ cargo run --bin stub_gen --features python
102134 - name : Build wheels
103135 uses : PyO3/maturin-action@v1
104136 with :
105137 target : ${{ matrix.platform.target }}
106- args : --release --features python --out dist --find-interpreter
138+ args : --release --features python --features pyo3/extension-module -- out dist --find-interpreter
107139 sccache : ${{ !startsWith(github.ref, 'refs/tags/') }}
140+ - name : Upload wheels
141+ uses : actions/upload-artifact@v4
142+ with :
143+ name : wheels-macos-${{ matrix.platform.target }}
144+ path : dist
108145
109146 sdist :
110147 runs-on : ubuntu-latest
111148 steps :
112149 - uses : actions/checkout@v4
150+ - name : Generate pyo3 stub
151+ run : |
152+ cargo run --bin stub_gen --features python
113153 - name : Build sdist
114154 uses : PyO3/maturin-action@v1
115155 with :
116156 command : sdist
117157 args : --out dist
158+ - name : Upload sdist
159+ uses : actions/upload-artifact@v4
160+ with :
161+ name : wheels-sdist
162+ path : dist
163+
164+ release :
165+ name : Release
166+ runs-on : ubuntu-latest
167+ if : ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
168+ needs : [linux, musllinux, windows, macos, sdist]
169+ permissions :
170+ # Use to sign the release artifacts
171+ id-token : write
172+ # Used to upload release artifacts
173+ contents : write
174+ # Used to generate artifact attestation
175+ attestations : write
176+ steps :
177+ - uses : actions/download-artifact@v4
178+ - name : Generate artifact attestation
179+ uses : actions/attest-build-provenance@v1
180+ with :
181+ subject-path : ' wheels-*/*'
182+ - name : Publish to PyPI
183+ if : ${{ startsWith(github.ref, 'refs/tags/') }}
184+ uses : PyO3/maturin-action@v1
185+ env :
186+ MATURIN_PYPI_TOKEN : ${{ secrets.PYPI_API_TOKEN }}
187+ with :
188+ command : upload
189+ args : --non-interactive --skip-existing wheels-*/*
0 commit comments