Skip to content

Commit ebf48b4

Browse files
committed
add cibuildwheel workflow
1 parent 6ca0df6 commit ebf48b4

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

.github/workflows/build_wheels.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build and publish wheels
2+
3+
on:
4+
release:
5+
types: [published]
6+
# Allow manual trigger for testing
7+
workflow_dispatch:
8+
9+
jobs:
10+
build_wheels:
11+
name: Build wheels on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: pypa/cibuildwheel@v2.22
22+
env:
23+
# Build for Python 3.10, 3.11, 3.12
24+
CIBW_BUILD: "cp310-* cp311-* cp312-*"
25+
# Skip 32-bit builds and musl linux
26+
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux*"
27+
# macOS: build both Intel and Apple Silicon
28+
CIBW_ARCHS_MACOS: "x86_64 arm64"
29+
CIBW_ARCHS_LINUX: "x86_64"
30+
CIBW_ARCHS_WINDOWS: "AMD64"
31+
# Build dependencies (pybind11 is needed at compile time)
32+
CIBW_BUILD_FRONTEND: "pip"
33+
# Test the built wheel
34+
CIBW_TEST_COMMAND: "python -c \"import SpatialQueryEliasFanoDB; print('C++ extension OK')\""
35+
36+
- uses: actions/upload-artifact@v4
37+
with:
38+
name: wheels-${{ matrix.os }}
39+
path: ./wheelhouse/*.whl
40+
41+
build_sdist:
42+
name: Build source distribution
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- uses: actions/setup-python@v5
48+
with:
49+
python-version: "3.12"
50+
51+
- run: pip install build
52+
53+
- run: python -m build --sdist
54+
55+
- uses: actions/upload-artifact@v4
56+
with:
57+
name: sdist
58+
path: dist/*.tar.gz
59+
60+
publish:
61+
name: Publish to PyPI
62+
needs: [build_wheels, build_sdist]
63+
runs-on: ubuntu-latest
64+
# Only publish on release events
65+
if: github.event_name == 'release'
66+
environment:
67+
name: pypi
68+
url: https://pypi.org/p/SpatialQuery
69+
permissions:
70+
id-token: write
71+
72+
steps:
73+
- uses: actions/download-artifact@v4
74+
with:
75+
path: dist/
76+
merge-multiple: true
77+
78+
- name: Publish to PyPI
79+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)