Skip to content

Commit 4818298

Browse files
authored
CI improvements to get publishing of rust bindings to work (#18)
2 parents 2ce0594 + 6049e83 commit 4818298

File tree

1 file changed

+150
-46
lines changed

1 file changed

+150
-46
lines changed

.github/workflows/ci.yaml

Lines changed: 150 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -70,66 +70,169 @@ jobs:
7070
- name: Check matrix job result
7171
run: test "$DEPS_RESULT" = "success"
7272

73-
build:
74-
name: Build distribution packages
73+
build-linux:
74+
runs-on: ${{ matrix.platform.runner }}
7575
strategy:
76-
fail-fast: false
7776
matrix:
78-
target:
79-
- ubuntu-24.04
80-
- ubuntu-24.04-arm
81-
- windows-latest
82-
- macos-15-intel
83-
- macos-15
84-
python:
85-
- "3.11"
86-
- "3.12"
87-
- "3.13"
88-
- "3.14"
89-
runs-on: ${{ matrix.target }}
77+
platform:
78+
- runner: ubuntu-22.04
79+
target: x86_64
80+
- runner: ubuntu-22.04
81+
target: aarch64
9082
steps:
91-
- name: Setup Git
92-
uses: frequenz-floss/[email protected]
83+
- uses: actions/checkout@v5
84+
- uses: actions/setup-python@v5
85+
with:
86+
python-version: 3.x
87+
- name: Build wheels
88+
uses: PyO3/maturin-action@v1
89+
with:
90+
target: ${{ matrix.platform.target }}
91+
args: --release --out dist --find-interpreter
92+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
93+
manylinux: auto
94+
- name: Upload wheels
95+
uses: actions/upload-artifact@v5
96+
with:
97+
name: wheels-linux-${{ matrix.platform.target }}
98+
path: dist
9399

94-
- name: Fetch sources
95-
uses: actions/checkout@v5
100+
build-musllinux:
101+
runs-on: ${{ matrix.platform.runner }}
102+
strategy:
103+
matrix:
104+
platform:
105+
- runner: ubuntu-22.04
106+
target: x86_64
107+
- runner: ubuntu-22.04
108+
target: aarch64
109+
steps:
110+
- uses: actions/checkout@v5
111+
- uses: actions/setup-python@v5
96112
with:
97-
submodules: true
113+
python-version: 3.x
114+
- name: Build wheels
115+
uses: PyO3/maturin-action@v1
116+
with:
117+
target: ${{ matrix.platform.target }}
118+
args: --release --out dist --find-interpreter
119+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
120+
manylinux: musllinux_1_2
121+
- name: Upload wheels
122+
uses: actions/upload-artifact@v5
123+
with:
124+
name: wheels-musllinux-${{ matrix.platform.target }}
125+
path: dist
98126

99-
- name: Setup Python
100-
uses: frequenz-floss/[email protected]
127+
build-windows:
128+
runs-on: ${{ matrix.platform.runner }}
129+
strategy:
130+
matrix:
131+
platform:
132+
- runner: windows-latest
133+
target: x64
134+
steps:
135+
- uses: actions/checkout@v5
136+
- uses: actions/setup-python@v5
101137
with:
102-
python-version: ${{ matrix.python }}
103-
dependencies: build
138+
python-version: 3.x
139+
architecture: ${{ matrix.platform.target }}
140+
- name: Build wheels
141+
uses: PyO3/maturin-action@v1
142+
with:
143+
target: ${{ matrix.platform.target }}
144+
args: --release --out dist --find-interpreter
145+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
146+
- name: Upload wheels
147+
uses: actions/upload-artifact@v5
148+
with:
149+
name: wheels-windows-${{ matrix.platform.target }}
150+
path: dist
104151

105-
- name: Build the source and binary distribution
106-
run: python -m build
152+
build-macos:
153+
runs-on: ${{ matrix.platform.runner }}
154+
strategy:
155+
matrix:
156+
platform:
157+
- runner: macos-15-intel
158+
target: x86_64
159+
- runner: macos-15
160+
target: aarch64
161+
steps:
162+
- uses: actions/checkout@v5
163+
- uses: actions/setup-python@v5
164+
with:
165+
python-version: 3.x
166+
- name: Build wheels
167+
uses: PyO3/maturin-action@v1
168+
with:
169+
target: ${{ matrix.platform.target }}
170+
args: --release --out dist --find-interpreter
171+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
172+
- name: Upload wheels
173+
uses: actions/upload-artifact@v5
174+
with:
175+
name: wheels-macos-${{ matrix.platform.target }}
176+
path: dist
107177

108-
- name: Upload distribution files
178+
build-sdist:
179+
name: Build source distribution packages
180+
runs-on: ubuntu-24.04
181+
steps:
182+
- uses: actions/checkout@v5
183+
- name: Build sdist
184+
uses: PyO3/maturin-action@v1
185+
with:
186+
command: sdist
187+
args: --out dist
188+
- name: Upload sdist
109189
uses: actions/upload-artifact@v5
110190
with:
111-
name: dist-packages-${{ matrix.target }}-${{ matrix.python }}
112-
path: dist/
113-
if-no-files-found: error
191+
name: wheels-sdist
192+
path: dist/*.tar.gz
114193

115194
test-installation:
116195
name: Test package installation
117-
needs: ["build"]
196+
needs:
197+
- "build-linux"
198+
- "build-musllinux"
199+
- "build-windows"
200+
- "build-macos"
201+
- "build-sdist"
118202
strategy:
119203
fail-fast: false
120204
matrix:
121-
target:
122-
- ubuntu-24.04
123-
- ubuntu-24.04-arm
124-
- windows-latest
125-
- macos-15-intel
126-
- macos-15
205+
platform:
206+
- runner: ubuntu-24.04
207+
image: linux
208+
tag: manylinux
209+
target: x86_64
210+
- runner: ubuntu-24.04-arm
211+
image: linux
212+
tag: manylinux
213+
target: aarch64
214+
- runner: windows-latest
215+
image: windows
216+
tag: win
217+
target: x64
218+
- runner: macos-15-intel
219+
image: macos
220+
tag: macosx
221+
target: x86_64
222+
- runner: macos-15
223+
image: macos
224+
tag: macosx
225+
target: aarch64
127226
python:
128-
- "3.11"
129-
- "3.12"
130-
- "3.13"
131-
- "3.14"
132-
runs-on: ${{ matrix.target }}
227+
- semver: "3.11"
228+
wheelver: cp311
229+
- semver: "3.12"
230+
wheelver: cp312
231+
- semver: "3.13"
232+
wheelver: cp313
233+
- semver: "3.14"
234+
wheelver: cp314
235+
runs-on: ${{ matrix.platform.runner }}
133236

134237
steps:
135238
- name: Setup Git
@@ -141,7 +244,7 @@ jobs:
141244
- name: Download package
142245
uses: actions/download-artifact@v6
143246
with:
144-
name: dist-packages-${{ matrix.target }}-${{ matrix.python }}
247+
name: wheels-${{ matrix.platform.image }}-${{ matrix.platform.target }}
145248
path: dist
146249

147250
# This is necessary for the `pip` caching in the setup-python action to work
@@ -162,8 +265,8 @@ jobs:
162265
- name: Setup Python
163266
uses: frequenz-floss/[email protected]
164267
with:
165-
python-version: ${{ matrix.python }}
166-
dependencies: dist/*.whl
268+
python-version: ${{ matrix.python.semver }}
269+
dependencies: dist/*${{ matrix.python.wheelver }}-${{ matrix.platform.tag }}*.whl
167270

168271
- name: Print installed packages (debug)
169272
run: python -m pip freeze
@@ -325,7 +428,7 @@ jobs:
325428
--generate-notes \
326429
$extra_opts \
327430
$REF_NAME \
328-
dist/dist-packages-*/*
431+
dist/wheels-*/*.whl dist/wheels-sdist/*.tar.gz
329432
env:
330433
REF_NAME: ${{ github.ref_name }}
331434
REPOSITORY: ${{ github.repository }}
@@ -344,6 +447,7 @@ jobs:
344447
uses: actions/download-artifact@v6
345448
with:
346449
path: dist
450+
merge-multiple: true
347451

348452
- name: Publish the Python distribution to PyPI
349453
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)