This repository was archived by the owner on Jul 12, 2026. It is now read-only.
Release #652
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| publish_target: | |
| description: "What to publish (both, crate-only, pypi-only)" | |
| type: choice | |
| options: | |
| - both | |
| - crate-only | |
| - pypi-only | |
| default: both | |
| permissions: | |
| contents: read | |
| jobs: | |
| linux: | |
| runs-on: ${{ matrix.platform.runner }} | |
| strategy: | |
| matrix: | |
| platform: | |
| - runner: ubuntu-latest | |
| target: x86_64 | |
| - runner: ubuntu-latest | |
| target: x86 | |
| - runner: ubuntu-24.04-arm | |
| target: aarch64 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up QEMU for ARM support | |
| if: matrix.platform.target == 'aarch64' | |
| uses: docker/setup-qemu-action@v3 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1.51.0 | |
| with: | |
| target: ${{ matrix.platform.target }} | |
| args: >- | |
| --release | |
| --out dist | |
| --bindings pyo3 | |
| --interpreter python3.10 python3.11 python3.12 python3.13 python3.14 | |
| --features extension-module${{ matrix.platform.target == 'aarch64' && ',vendored-openssl' || '' }} | |
| sccache: 'true' | |
| manylinux: 2_28 | |
| before-script-linux: | | |
| if command -v yum &> /dev/null; then | |
| yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic | |
| # If we're running on i686 we need to symlink libatomic | |
| # in order to build openssl with -latomic flag. | |
| if [[ ! -d "/usr/lib64" ]]; then | |
| ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so | |
| fi | |
| else | |
| # If we're running on debian-based system. | |
| apt update -y && apt-get install -y libssl-dev openssl pkg-config | |
| fi | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheels-linux-${{ matrix.platform.target }} | |
| path: dist | |
| macos: | |
| runs-on: ${{ matrix.platform.runner }} | |
| strategy: | |
| matrix: | |
| platform: | |
| - runner: macos-15-intel | |
| target: x86_64 | |
| - runner: macos-latest | |
| target: aarch64 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1.51.0 | |
| with: | |
| target: ${{ matrix.platform.target }} | |
| args: --release --out dist --bindings pyo3 --features extension-module --interpreter python3.10 python3.11 python3.12 python3.13 python3.14 | |
| sccache: 'true' | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheels-macos-${{ matrix.platform.target }} | |
| path: dist | |
| sdist: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build sdist | |
| uses: PyO3/maturin-action@v1.51.0 | |
| with: | |
| command: sdist | |
| args: --out dist | |
| - name: Upload sdist | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheels-sdist | |
| path: dist | |
| # Verify crate builds, tests pass, and package is valid (runs on all triggers) | |
| check-crate: | |
| name: Verify crate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update && | |
| sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler pkg-config | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Check compilation | |
| run: cargo check --all-targets | |
| - name: Run tests | |
| run: cargo test --lib --tests | |
| - name: Verify package | |
| run: cargo package | |
| # Publish Rust crate to crates.io (gate for PyPI on full release) | |
| release-crate: | |
| name: Publish to crates.io | |
| runs-on: ubuntu-latest | |
| needs: [check-crate] | |
| environment: release | |
| if: >- | |
| (startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch') | |
| && (github.event.inputs.publish_target != 'pypi-only') | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update && | |
| sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler pkg-config | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Verify crate version matches tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| CRATE_VERSION="v$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')" | |
| TAG_NAME="${GITHUB_REF#refs/tags/}" | |
| if [ "$CRATE_VERSION" != "$TAG_NAME" ]; then | |
| echo "::error::Crate version ($CRATE_VERSION) does not match tag ($TAG_NAME)" | |
| exit 1 | |
| fi | |
| - name: Publish to crates.io | |
| run: cargo publish --no-verify | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| # Publish Python wheels to PyPI | |
| release-pypi: | |
| name: Publish to PyPI | |
| runs-on: ubuntu-latest | |
| environment: release | |
| needs: | |
| - linux | |
| - macos | |
| - sdist | |
| - release-crate | |
| if: >- | |
| always() | |
| && (startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch') | |
| && (github.event.inputs.publish_target != 'crate-only') | |
| && (needs.linux.result == 'success') | |
| && (needs.macos.result == 'success') | |
| && (needs.sdist.result == 'success') | |
| && (needs.release-crate.result == 'success' || needs.release-crate.result == 'skipped') | |
| permissions: | |
| # Use to sign the release artifacts | |
| id-token: write | |
| # Used to upload release artifacts | |
| contents: write | |
| # Used to generate artifact attestation | |
| attestations: write | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| - name: Generate artifact attestation | |
| uses: actions/attest-build-provenance@v4.1.0 | |
| with: | |
| subject-path: 'wheels-*/*' | |
| - name: Publish to PyPI | |
| uses: PyO3/maturin-action@v1.51.0 | |
| with: | |
| command: upload | |
| args: --non-interactive --skip-existing wheels-*/* |