cridecoder 0.2.0

CRI codec library for ACB/AWB, HCA audio, and USM video extraction
Documentation
name: Release Python

on:
  release:
    types: [published]
  workflow_dispatch:

permissions:
  contents: read

env:
  # Extract version from tag (strips 'v' prefix), fallback to 0.0.0 for workflow_dispatch
  RELEASE_VERSION: ${{ github.event_name == 'release' && github.ref_name || 'v0.0.0' }}

jobs:
  # ──────────────────────────────────────────────
  # Build wheels for Linux (x86_64, aarch64)
  # ──────────────────────────────────────────────
  linux:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target: [x86_64, aarch64]
    steps:
      - uses: actions/checkout@v6
      - name: Set version from tag
        if: github.event_name == 'release'
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          sed -i "0,/^version = .*/s//version = \"${VERSION}\"/" Cargo.toml
          sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --find-interpreter
          sccache: "true"
          manylinux: auto
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-linux-${{ matrix.target }}
          path: dist

  # ──────────────────────────────────────────────
  # Build wheels for macOS (x86_64, aarch64)
  # ──────────────────────────────────────────────
  macos:
    runs-on: macos-15
    strategy:
      matrix:
        target: [x86_64, aarch64]
    steps:
      - uses: actions/checkout@v6
      - name: Set version from tag
        if: github.event_name == 'release'
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          sed -i '' "1,/^version = .*/{s/^version = .*/version = \"${VERSION}\"/;}" Cargo.toml
          sed -i '' "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml
      - uses: actions/setup-python@v5
        with:
          python-version: |
            3.9
            3.10
            3.11
            3.12
            3.13
            3.14
            3.14t
          allow-prereleases: true
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --find-interpreter
          sccache: "true"
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-macos-${{ matrix.target }}
          path: dist

  # ──────────────────────────────────────────────
  # Build wheels for Windows (x86_64)
  # ──────────────────────────────────────────────
  windows:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v6
      - name: Set version from tag
        if: github.event_name == 'release'
        shell: bash
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          sed -i "0,/^version = .*/s//version = \"${VERSION}\"/" Cargo.toml
          sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml
      - uses: actions/setup-python@v5
        with:
          python-version: |
            3.9
            3.10
            3.11
            3.12
            3.13
            3.14
            3.14t
          allow-prereleases: true
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: x64
          args: --release --out dist --find-interpreter
          sccache: "true"
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-windows-x64
          path: dist

  # ──────────────────────────────────────────────
  # Build source distribution
  # ──────────────────────────────────────────────
  sdist:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Set version from tag
        if: github.event_name == 'release'
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          sed -i "0,/^version = .*/s//version = \"${VERSION}\"/" Cargo.toml
          sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml
      - name: Build sdist
        uses: PyO3/maturin-action@v1
        with:
          command: sdist
          args: --out dist
      - name: Upload sdist
        uses: actions/upload-artifact@v7
        with:
          name: wheels-sdist
          path: dist

  # ──────────────────────────────────────────────
  # Publish all wheels + sdist to PyPI
  # ──────────────────────────────────────────────
  publish:
    name: Publish to PyPI
    runs-on: ubuntu-latest
    needs: [linux, macos, windows, sdist]
    if: github.event_name == 'release'
    environment:
      name: pypi
      url: https://pypi.org/p/cridecoder
    permissions:
      id-token: write
    steps:
      - uses: actions/download-artifact@v8
        with:
          pattern: wheels-*
          merge-multiple: true
          path: dist/
      - name: Publish to PyPI
        uses: PyO3/maturin-action@v1
        with:
          command: upload
          args: --non-interactive --skip-existing dist/*