Skip to content

Commit 625f54c

Browse files
committed
feat: add reusable maturin prerelease workflow for multi-platform builds
Adds reusable_maturin_prerelease.yml — a drop-in replacement for reusable_prerelease.yml for packages that use PyO3/maturin instead of hatch. Builds native wheels on a configurable platform matrix (defaults to all 6 platforms: linux x86_64/aarch64, windows x86_64/aarch64, macOS arm64/x86_64), plus sdist, and collects them into a single build-artifact upload matching the format reusable_release.yml expects. Inputs: - tag (required): git tag to build from - platforms (optional): JSON array of {os, target, manylinux} objects - version-script (optional): shell command to inject VCS version Signed-off-by: Jericho Tolentino <68654047+jericht@users.noreply.github.com>
1 parent 0685762 commit 625f54c

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: "Prerelease: Maturin (multi-platform)"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag:
7+
required: true
8+
type: string
9+
platforms:
10+
required: false
11+
type: string
12+
description: >
13+
JSON array of platform objects. Each must have "os" and "target".
14+
Optional: "manylinux" (default "auto").
15+
Default builds all 6 supported platforms.
16+
default: >
17+
[
18+
{ "os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu", "manylinux": "auto" },
19+
{ "os": "ubuntu-latest", "target": "aarch64-unknown-linux-gnu", "manylinux": "auto" },
20+
{ "os": "windows-latest", "target": "x86_64-pc-windows-msvc" },
21+
{ "os": "windows-11-arm", "target": "aarch64-pc-windows-msvc" },
22+
{ "os": "macos-latest", "target": "aarch64-apple-darwin" },
23+
{ "os": "macos-15-intel", "target": "x86_64-apple-darwin" }
24+
]
25+
version-script:
26+
required: false
27+
type: string
28+
description: >
29+
Shell command to inject VCS version before building.
30+
Run in bash. Skipped if empty.
31+
default: "pip install setuptools_scm && python scripts/maturin_build.py --version-only"
32+
33+
jobs:
34+
BuildWheels:
35+
name: Build wheel (${{ matrix.platform.os }} / ${{ matrix.platform.target }})
36+
runs-on: ${{ matrix.platform.os }}
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
platform: ${{ fromJson(inputs.platforms) }}
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
with:
45+
ref: refs/tags/${{ inputs.tag }}
46+
fetch-depth: 0
47+
48+
- name: Set up Python
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: "3.12"
52+
53+
- name: Inject version
54+
if: inputs.version-script != ''
55+
run: ${{ inputs.version-script }}
56+
shell: bash
57+
58+
- name: Build wheel
59+
uses: PyO3/maturin-action@v1
60+
with:
61+
target: ${{ matrix.platform.target }}
62+
manylinux: ${{ matrix.platform.manylinux || 'auto' }}
63+
args: --release --out dist
64+
65+
- name: Upload wheel
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: wheels-${{ matrix.platform.os }}-${{ matrix.platform.target }}
69+
path: dist/*.whl
70+
71+
BuildSdist:
72+
name: Build sdist
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v4
77+
with:
78+
ref: refs/tags/${{ inputs.tag }}
79+
fetch-depth: 0
80+
81+
- name: Build sdist
82+
uses: PyO3/maturin-action@v1
83+
with:
84+
command: sdist
85+
args: --out dist
86+
87+
- name: Upload sdist
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: sdist
91+
path: dist/*.tar.gz
92+
93+
CollectArtifacts:
94+
name: Collect build artifacts
95+
needs: [BuildWheels, BuildSdist]
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/download-artifact@v4
99+
with:
100+
path: dist
101+
merge-multiple: true
102+
103+
- name: List artifacts
104+
run: ls -la dist/
105+
106+
- uses: actions/upload-artifact@v4
107+
with:
108+
name: build-artifact
109+
path: dist

0 commit comments

Comments
 (0)