33on :
44 push :
55 branches : [ main ]
6+ tags :
7+ - ' v*'
68 pull_request :
79 branches : [ main ]
810
@@ -178,4 +180,115 @@ jobs:
178180 fi
179181 cd rapidgeo-py
180182 python tests/test_rapidgeo.py
181- shell : bash
183+ shell : bash
184+
185+ build-wheels :
186+ name : Build wheels on ${{ matrix.os }}
187+ runs-on : ${{ matrix.os }}
188+ needs : [test-rust, test-python]
189+ if : startsWith(github.ref, 'refs/tags/')
190+ strategy :
191+ matrix :
192+ include :
193+ - os : ubuntu-latest
194+ target : x86_64
195+ - os : ubuntu-latest
196+ target : aarch64
197+ - os : windows-latest
198+ target : x64
199+ - os : macos-latest
200+ target : x86_64
201+ - os : macos-14
202+ target : aarch64
203+
204+ steps :
205+ - uses : actions/checkout@v4
206+
207+ - name : Build wheels
208+ uses : PyO3/maturin-action@v1
209+ with :
210+ target : ${{ matrix.target }}
211+ args : --release --out dist --find-interpreter
212+ sccache : ' true'
213+ manylinux : auto
214+ working-directory : rapidgeo-py
215+
216+ - name : Upload wheels
217+ uses : actions/upload-artifact@v4
218+ with :
219+ name : wheels-${{ matrix.os }}-${{ matrix.target }}
220+ path : dist
221+
222+ build-sdist :
223+ name : Build source distribution
224+ runs-on : ubuntu-latest
225+ needs : [test-rust, test-python]
226+ if : startsWith(github.ref, 'refs/tags/')
227+ steps :
228+ - uses : actions/checkout@v4
229+
230+ - name : Build sdist
231+ uses : PyO3/maturin-action@v1
232+ with :
233+ command : sdist
234+ args : --out dist
235+ working-directory : rapidgeo-py
236+
237+ - name : Upload sdist
238+ uses : actions/upload-artifact@v4
239+ with :
240+ name : wheels-sdist
241+ path : dist
242+
243+ publish :
244+ name : Publish to PyPI
245+ runs-on : ubuntu-latest
246+ needs : [build-wheels, build-sdist]
247+ if : startsWith(github.ref, 'refs/tags/')
248+
249+ steps :
250+ - name : Download all artifacts
251+ uses : actions/download-artifact@v4
252+ with :
253+ pattern : wheels-*
254+ path : dist
255+ merge-multiple : true
256+
257+ - name : Publish to PyPI
258+ uses : PyO3/maturin-action@v1
259+ env :
260+ MATURIN_PYPI_TOKEN : ${{ secrets.PYPI_TOKEN }}
261+ with :
262+ command : upload
263+ args : --non-interactive --skip-existing dist/*
264+
265+ publish-crates :
266+ name : Publish Rust crates to crates.io
267+ runs-on : ubuntu-latest
268+ needs : [test-rust]
269+ if : startsWith(github.ref, 'refs/tags/')
270+
271+ steps :
272+ - uses : actions/checkout@v4
273+
274+ - name : Install Rust
275+ uses : dtolnay/rust-toolchain@stable
276+
277+ - name : Cache Cargo
278+ uses : actions/cache@v4
279+ with :
280+ path : |
281+ ~/.cargo/bin/
282+ ~/.cargo/registry/index/
283+ ~/.cargo/registry/cache/
284+ ~/.cargo/git/db/
285+ target/
286+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
287+
288+ - name : Publish to crates.io
289+ env :
290+ CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
291+ run : |
292+ cargo publish -p rapidgeo-distance --allow-dirty
293+ cargo publish -p rapidgeo-simplify --allow-dirty
294+ cargo publish -p rapidgeo-polyline --allow-dirty
0 commit comments