Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/reusable_maturin_prerelease.yml
Original file line number Diff line number Diff line change
@@ -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" },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that Github has this! Or is this cross compilation. ( only a note, not a comment or anything )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a build matrix, we can choose different platforms to run our actions on. It's the same way we run the unit tests on multiple platforms

{ "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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. No timeout on jobs

The matrix build runs across 6 platform runners. If a runner hangs (particularly cross-compilation for aarch64-unknown-linux-gnu via QEMU in maturin-action), there's no timeout-minutes. Default GitHub timeout is
6 hours per job. Adding timeout-minutes: 30 (or similar) would prevent stuck releases from burning Actions minutes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the python version specified here mean that these wheels will only work for 3.12 and above ? Or is this something else

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the Python version used by the GitHub Action runner. It's used to run the build (maturin). This version shouldn't matter since it's only used by the machine building. Let me double check maturin docs


- 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