-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add reusable maturin prerelease workflow for multi-platform builds #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" }, | ||
| { "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: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( |
||
|
|
||
| - 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 | ||
There was a problem hiding this comment.
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 )
There was a problem hiding this comment.
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