Skip to content

Commit f7b17ab

Browse files
feat(cicd): build wheels for PyPI (#96)
1 parent fea221e commit f7b17ab

File tree

2 files changed

+188
-25
lines changed

2 files changed

+188
-25
lines changed

.github/workflows/release.yaml

Lines changed: 187 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,197 @@
1-
name: Upload Python Package
1+
name: Build and Publish Wheels
22

33
on:
4-
push:
5-
branches:
6-
- dev
74
release:
85
branches:
96
- master
107
types: [published]
118

129
jobs:
13-
deploy:
14-
runs-on: ubuntu-latest
10+
build_wheels:
11+
name: Build wheels using cibuildwheel
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
# ----------------------------------------------------
18+
# manylinux 64-bit
19+
# ----------------------------------------------------
20+
- os: ubuntu-latest
21+
build_type: manylinux-x64
22+
cibw_build: "*manylinux*"
23+
cibw_archs_linux: x86_64
24+
artifact_name: "wheels-ubuntu-latest-manylinux-x64"
25+
26+
# ----------------------------------------------------
27+
# manylinux 32-bit
28+
# ----------------------------------------------------
29+
- os: ubuntu-latest
30+
build_type: manylinux-x86
31+
cibw_build: "*manylinux*"
32+
cibw_archs_linux: i686
33+
artifact_name: "wheels-ubuntu-latest-manylinux-x86"
34+
35+
# ----------------------------------------------------
36+
# musllinux 64-bit
37+
# ----------------------------------------------------
38+
- os: ubuntu-latest
39+
build_type: musllinux-x64
40+
cibw_build: "*musllinux*"
41+
cibw_archs_linux: x86_64
42+
artifact_name: "wheels-ubuntu-latest-musllinux-x64"
43+
44+
# ----------------------------------------------------
45+
# musllinux 32-bit
46+
# ----------------------------------------------------
47+
- os: ubuntu-latest
48+
build_type: musllinux-x86
49+
cibw_build: "*musllinux*"
50+
cibw_archs_linux: i686
51+
artifact_name: "wheels-ubuntu-latest-musllinux-x86"
52+
53+
# ----------------------------------------------------
54+
# macOS (64-bit only)
55+
# ----------------------------------------------------
56+
- os: macos-latest
57+
build_type: macos
58+
cibw_build: ""
59+
cibw_archs_linux: ""
60+
artifact_name: "wheels-macos-latest"
61+
62+
# ----------------------------------------------------
63+
# Windows 64-bit
64+
# ----------------------------------------------------
65+
- os: windows-latest
66+
build_type: winx64
67+
cibw_build: ""
68+
cibw_archs_windows: AMD64
69+
artifact_name: "wheels-windows-latest-x64"
70+
71+
# ----------------------------------------------------
72+
# Windows 32-bit
73+
# ----------------------------------------------------
74+
- os: windows-latest
75+
build_type: winx86
76+
cibw_build: ""
77+
cibw_archs_windows: x86
78+
artifact_name: "wheels-windows-latest-x86"
79+
80+
steps:
81+
- name: Check out code
82+
uses: actions/checkout@v3
83+
with:
84+
fetch-depth: 0
85+
86+
- name: Set up Python
87+
uses: actions/setup-python@v4
88+
with:
89+
python-version: "3.11"
90+
91+
- name: Install cibuildwheel
92+
run: |
93+
python -m pip install --upgrade pip setuptools wheel cibuildwheel
94+
95+
- name: Build wheels
96+
env:
97+
# On Linux: manylinux / musllinux arches
98+
CIBW_ARCHS_LINUX: ${{ matrix.cibw_archs_linux || '' }}
99+
# On Windows: AMD64 / x86
100+
CIBW_ARCHS_WINDOWS: ${{ matrix.cibw_archs_windows || '' }}
101+
# Which wheels to build for Linux (manylinux vs. musllinux)
102+
CIBW_BUILD: ${{ matrix.cibw_build || '' }}
103+
run: |
104+
python -m cibuildwheel --output-dir wheelhouse
15105
106+
- name: Upload wheels
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: ${{ matrix.artifact_name }}
110+
path: wheelhouse/*.whl
111+
112+
publish_sdist_and_wheels:
113+
name: Publish wheels to PyPI
114+
needs: build_wheels
115+
runs-on: ubuntu-latest
16116
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4.1.4
19-
with:
20-
fetch-depth: 0
21-
persist-credentials: false
22-
23-
- name: Setup Python
24-
uses: actions/setup-python@v5
25-
with:
26-
python-version: "3.9"
27-
28-
- name: Install Poetry
29-
uses: snok/install-poetry@v1
30-
31-
- name: Build and Publish
32-
run: |
33-
poetry config pypi-token.pypi ${{ secrets.PYPI_PASSWORD }}
34-
poetry build --format sdist
35-
poetry publish --no-interaction
117+
- name: Check out code
118+
uses: actions/checkout@v3
119+
with:
120+
fetch-depth: 0
121+
122+
- name: Set up Python
123+
uses: actions/setup-python@v4
124+
with:
125+
python-version: "3.11"
126+
127+
- name: Install dependencies
128+
run: |
129+
python -m pip install --upgrade pip
130+
pip install setuptools wheel twine mypy[mypyc]
131+
132+
- name: Build sdist
133+
run: |
134+
python setup.py sdist
135+
136+
# ----------------------------------------------------
137+
# Download wheels built on each runner
138+
# ----------------------------------------------------
139+
- name: Download manylinux 64-bit wheels
140+
uses: actions/download-artifact@v4
141+
with:
142+
name: "wheels-ubuntu-latest-manylinux-x64"
143+
path: wheelhouse/linux-many-x64
144+
145+
- name: Download manylinux 32-bit wheels
146+
uses: actions/download-artifact@v4
147+
with:
148+
name: "wheels-ubuntu-latest-manylinux-x86"
149+
path: wheelhouse/linux-many-x86
150+
151+
- name: Download musllinux 64-bit wheels
152+
uses: actions/download-artifact@v4
153+
with:
154+
name: "wheels-ubuntu-latest-musllinux-x64"
155+
path: wheelhouse/linux-musl-x64
156+
157+
- name: Download musllinux 32-bit wheels
158+
uses: actions/download-artifact@v4
159+
with:
160+
name: "wheels-ubuntu-latest-musllinux-x86"
161+
path: wheelhouse/linux-musl-x86
162+
163+
- name: Download macOS wheels
164+
uses: actions/download-artifact@v4
165+
with:
166+
name: "wheels-macos-latest"
167+
path: wheelhouse/macos
168+
169+
- name: Download Windows 64-bit wheels
170+
uses: actions/download-artifact@v4
171+
with:
172+
name: "wheels-windows-latest-x64"
173+
path: wheelhouse/windows-x64
174+
175+
- name: Download Windows 32-bit wheels
176+
uses: actions/download-artifact@v4
177+
with:
178+
name: "wheels-windows-latest-x86"
179+
path: wheelhouse/windows-x86
180+
181+
# ----------------------------------------------------
182+
# Publish all built artifacts to PyPI
183+
# ----------------------------------------------------
184+
- name: Publish sdist and wheels to PyPI
185+
env:
186+
TWINE_USERNAME: __token__
187+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
188+
run: |
189+
twine upload \
190+
dist/* \
191+
wheelhouse/linux-many-x64/*.whl \
192+
wheelhouse/linux-many-x86/*.whl \
193+
wheelhouse/linux-musl-x64/*.whl \
194+
wheelhouse/linux-musl-x86/*.whl \
195+
wheelhouse/macos/*.whl \
196+
wheelhouse/windows-x64/*.whl \
197+
wheelhouse/windows-x86/*.whl

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def combine_markers(a, b):
152152
setup(
153153
name=poetry_config["name"],
154154
version=poetry_config["version"],
155+
python_requires=">=3.8,<3.13",
155156
packages=find_packages(),
156157
package_data={"evmspec": ["py.typed"]},
157158
include_package_data=True,

0 commit comments

Comments
 (0)