From 962ae40fc6e0e184bb108993df06c84865a7033c Mon Sep 17 00:00:00 2001 From: jericht <68654047+jericht@users.noreply.github.com> Date: Thu, 18 Jun 2026 21:28:28 +0000 Subject: [PATCH] feat: add reusable maturin prerelease workflow for multi-platform builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: jericht <68654047+jericht@users.noreply.github.com> --- .../workflows/reusable_maturin_prerelease.yml | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 .github/workflows/reusable_maturin_prerelease.yml diff --git a/.github/workflows/reusable_maturin_prerelease.yml b/.github/workflows/reusable_maturin_prerelease.yml new file mode 100644 index 0000000..5a0ac8a --- /dev/null +++ b/.github/workflows/reusable_maturin_prerelease.yml @@ -0,0 +1,113 @@ +name: "Prerelease: Maturin (multi-platform)" + +on: + workflow_call: + inputs: + tag: + required: true + type: string + platforms: + required: false + type: string + description: > + JSON array of platform objects. Each must have "os" and "target". + Optional: "manylinux" (default "auto"). + Default builds all 6 supported platforms. + default: > + [ + { "os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu", "manylinux": "auto" }, + { "os": "ubuntu-latest", "target": "aarch64-unknown-linux-gnu", "manylinux": "auto" }, + { "os": "windows-latest", "target": "x86_64-pc-windows-msvc" }, + { "os": "windows-11-arm", "target": "aarch64-pc-windows-msvc" }, + { "os": "macos-latest", "target": "aarch64-apple-darwin" }, + { "os": "macos-15-intel", "target": "x86_64-apple-darwin" } + ] + version-script: + required: false + type: string + description: > + Shell command to inject VCS version before building. + Run in bash. Skipped if empty. + default: "pip install setuptools_scm && python scripts/maturin_build.py --version-only" + +jobs: + BuildWheels: + name: Build wheel (${{ matrix.platform.os }} / ${{ matrix.platform.target }}) + runs-on: ${{ matrix.platform.os }} + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + platform: ${{ fromJson(inputs.platforms) }} + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: refs/tags/${{ inputs.tag }} + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Inject version + if: inputs.version-script != '' + run: ${{ inputs.version-script }} + shell: bash + + - name: Build wheel + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + manylinux: ${{ matrix.platform.manylinux || 'auto' }} + rust-toolchain: stable + args: --release --out dist + + - name: Upload wheel + uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.platform.os }}-${{ matrix.platform.target }} + path: dist/*.whl + + BuildSdist: + name: Build sdist + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: refs/tags/${{ inputs.tag }} + fetch-depth: 0 + + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: sdist + path: dist/*.tar.gz + + CollectArtifacts: + name: Collect build artifacts + needs: [BuildWheels, BuildSdist] + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + + - name: List artifacts + run: ls -la dist/ + + - uses: actions/upload-artifact@v4 + with: + name: build-artifact + path: dist