Skip to content

feat: configure PyO3 test environment in CI workflows #2

feat: configure PyO3 test environment in CI workflows

feat: configure PyO3 test environment in CI workflows #2

name: Publish Python Packages

Check failure on line 1 in .github/workflows/publish-python.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish-python.yml

Invalid workflow file

(Line: 24, Col: 9): Unrecognized named-value: 'matrix'. Located at position 89 within expression: github.event.inputs.target == 'all' || (github.event.inputs.target == 'bootstrap-1' && (matrix.package_path == 'tstring-core' || matrix.package_path == 'json-tstring')) || (github.event.inputs.target == 'bootstrap-2' && (matrix.package_path == 'toml-tstring' || matrix.package_path == 'yaml-tstring')), (Line: 156, Col: 9): Unrecognized named-value: 'matrix'. Located at position 89 within expression: github.event.inputs.target == 'all' || (github.event.inputs.target == 'bootstrap-1' && (matrix.package_path == 'tstring-core' || matrix.package_path == 'json-tstring')) || (github.event.inputs.target == 'bootstrap-2' && (matrix.package_path == 'toml-tstring' || matrix.package_path == 'yaml-tstring'))
on:
workflow_dispatch:
inputs:
target:
description: "Package set to publish"
required: true
default: bootstrap-1
type: choice
options:
- bootstrap-1
- bootstrap-2
- all
env:
PURE_PYTHON_ARTIFACT_PREFIX: python-distributions
permissions:
contents: read
jobs:
build-package:
if: ${{ github.event.inputs.target == 'all' || (github.event.inputs.target == 'bootstrap-1' && (matrix.package_path == 'tstring-core' || matrix.package_path == 'json-tstring')) || (github.event.inputs.target == 'bootstrap-2' && (matrix.package_path == 'toml-tstring' || matrix.package_path == 'yaml-tstring')) }}
strategy:
matrix:
package_path:
- tstring-core
- json-tstring
- toml-tstring
- yaml-tstring
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.14"
- name: Set up Rust
uses: dtolnay/rust-toolchain@1.94.0
- name: Build distribution
run: uv build "${{ matrix.package_path }}" --out-dir dist
- name: Check distribution metadata
run: uvx twine check dist/*
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: ${{ env.PURE_PYTHON_ARTIFACT_PREFIX }}-${{ matrix.package_path }}
path: dist/*
build-bindings-wheels:
if: ${{ github.event.inputs.target == 'all' || github.event.inputs.target == 'bootstrap-1' }}
strategy:
matrix:
include:
- os: linux
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
maturin_args: --release --manifest-path rust/python-bindings/Cargo.toml --out dist --compatibility pypi -i python3.14
- os: macos
runner: macos-14
target: aarch64-apple-darwin
maturin_args: --release --manifest-path rust/python-bindings/Cargo.toml --out dist --compatibility pypi
- os: windows
runner: windows-latest
target: x86_64-pc-windows-msvc
maturin_args: --release --manifest-path rust/python-bindings/Cargo.toml --out dist --compatibility pypi
runs-on: ${{ matrix.runner }}
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.14"
- name: Set up Rust
uses: dtolnay/rust-toolchain@1.94.0
with:
targets: ${{ matrix.target }}
- name: Build bindings wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: ${{ matrix.maturin_args }}
manylinux: "2_28"
sccache: "true"
- name: Check distribution metadata
run: uvx twine check dist/*
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: bindings-wheels-${{ matrix.os }}
path: dist/*
build-bindings-sdist:
if: ${{ github.event.inputs.target == 'all' || github.event.inputs.target == 'bootstrap-1' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.14"
- name: Set up Rust
uses: dtolnay/rust-toolchain@1.94.0
- name: Build source distribution
run: uvx maturin sdist --manifest-path rust/python-bindings/Cargo.toml --out dist
- name: Check distribution metadata
run: uvx twine check dist/*
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: bindings-sdist
path: dist/*
publish-package:
strategy:
matrix:
include:
- package_path: tstring-core
environment_name: pypi-tstring-core
- package_path: json-tstring
environment_name: pypi-json-tstring
- package_path: toml-tstring
environment_name: pypi-toml-tstring
- package_path: yaml-tstring
environment_name: pypi-yaml-tstring
runs-on: ubuntu-latest
needs: build-package
if: ${{ github.event.inputs.target == 'all' || (github.event.inputs.target == 'bootstrap-1' && (matrix.package_path == 'tstring-core' || matrix.package_path == 'json-tstring')) || (github.event.inputs.target == 'bootstrap-2' && (matrix.package_path == 'toml-tstring' || matrix.package_path == 'yaml-tstring')) }}
environment:
name: ${{ matrix.environment_name }}
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: ${{ env.PURE_PYTHON_ARTIFACT_PREFIX }}-${{ matrix.package_path }}
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-bindings:
runs-on: ubuntu-latest
needs:
- build-bindings-wheels
- build-bindings-sdist
if: ${{ github.event.inputs.target == 'all' || github.event.inputs.target == 'bootstrap-1' }}
environment:
name: pypi-tstring-bindings
permissions:
id-token: write
steps:
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: bindings-wheels-*
path: dist/
merge-multiple: true
- name: Download source distribution
uses: actions/download-artifact@v4
with:
name: bindings-sdist
path: dist/
- name: Check distribution metadata
run: uvx twine check dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1