Skip to content

feat: add reusable maturin prerelease workflow for multi-platform builds#17

Merged
jericht merged 1 commit into
OpenJobDescription:mainlinefrom
jericht:jericht/reusable-maturin-build
Jun 23, 2026
Merged

feat: add reusable maturin prerelease workflow for multi-platform builds#17
jericht merged 1 commit into
OpenJobDescription:mainlinefrom
jericht:jericht/reusable-maturin-build

Conversation

@jericht

@jericht jericht commented Jun 18, 2026

Copy link
Copy Markdown

See description for OpenJobDescription/openjd-model-for-python#281

This PR just has the reusable workflows for above PR, will be reused in openjd-sessions package too


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jericht
jericht force-pushed the jericht/reusable-maturin-build branch from 625f54c to c0628c4 Compare June 19, 2026 17:28
@jericht
jericht marked this pull request as ready for review June 20, 2026 00:36
@jericht
jericht requested a review from a team as a code owner June 20, 2026 00:36
{ "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

uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  3. No --locked flag on maturin-action build
  
  args: --release --out dist
  
  Without --locked, Cargo may resolve newer dependency versions than what's in Cargo.lock. For reproducible release builds, you should pass --locked to ensure the lock file is respected:

This one seems interesting and important. We want to use the package version lock.

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.

Hmm this is causing issues in the build: https://github.com/jericht/openjd-model-for-python/actions/runs/28043947356/job/83017094879

Let me look into what the flag does.

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.

Here is the CLI help text for maturin build --sdist

      --locked
          Require Cargo.lock is up to date

Apparently this is actually a cargo option (source)

Relevant cargo docs (source):

--locked
Asserts that the exact same dependencies and versions are used as when the existing Cargo.lock file was originally generated. Cargo will exit with an error when either of the following scenarios arises:

The lock file is missing.
Cargo attempted to change the lock file due to a different dependency resolution.
It may be used in environments where deterministic builds are desired, such as in CI pipelines.

So I think we do want --locked, just not sure why it's failing. Let me look into it

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.

Oh I think I may have added a Cargo.lock at the root of the repo when it should be in rust-bindings

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.

I just needed to tag the latest commit and give the workflow the new tag. Fixed

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit - seems the other PR uses v6, do we need to upgrade?

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.

Upgraded

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

@jericht
jericht force-pushed the jericht/reusable-maturin-build branch 3 times, most recently from c169ef9 to 95f0134 Compare June 23, 2026 18:18
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>
@jericht
jericht force-pushed the jericht/reusable-maturin-build branch from 95f0134 to 962ae40 Compare June 23, 2026 18:22
@jericht

jericht commented Jun 23, 2026

Copy link
Copy Markdown
Author

@jericht
jericht requested a review from leongdl June 23, 2026 18:24
- 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

@jericht
jericht dismissed leongdl’s stale review June 23, 2026 19:06

Sufficient approvals, addressed comments

@jericht
jericht merged commit 1a99a7e into OpenJobDescription:mainline Jun 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants