dtcs 0.1.1

Reference implementation of the Data Transformation Contract Standard (DTCS)
Documentation
name: Release

on:
  push:
    tags:
      - "v*.*.*"

env:
  CARGO_TERM_COLOR: always
  CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
  MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

jobs:
  checks:
    uses: ./.github/workflows/checks.yml

  publish-crates-io:
    needs: checks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Verify tag matches crate and Python versions
        run: |
          crate_version=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
          py_version=$(grep '^version' pyproject.toml | head -1 | cut -d'"' -f2)
          tag_version="${GITHUB_REF_NAME#v}"
          if [ "$crate_version" != "$tag_version" ]; then
            echo "Tag ${GITHUB_REF_NAME} (v${tag_version}) does not match Cargo.toml version ${crate_version}"
            exit 1
          fi
          if [ "$py_version" != "$tag_version" ]; then
            echo "Tag ${GITHUB_REF_NAME} (v${tag_version}) does not match pyproject.toml version ${py_version}"
            exit 1
          fi
      - name: cargo publish
        run: cargo publish --locked --token "$CARGO_REGISTRY_TOKEN"

  build-python:
    needs: checks
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            build-sdist: true
          - os: macos-latest
            build-sdist: false
          - os: windows-latest
            build-sdist: false
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install macOS Rust targets
        if: runner.os == 'macOS'
        run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
      - name: Install maturin
        run: pip install maturin
      - name: Build wheels (macOS universal)
        if: runner.os == 'macOS'
        run: maturin build --release --features python --locked -i universal2 --out dist
      - name: Build wheels
        if: runner.os != 'macOS'
        run: maturin build --release --features python --locked --out dist
      - name: Build sdist
        if: matrix.build-sdist
        run: maturin sdist --out dist
      - uses: actions/upload-artifact@v4
        with:
          name: python-dist-${{ matrix.os }}
          path: dist/*
          if-no-files-found: error

  publish-pypi:
    needs: build-python
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          pattern: python-dist-*
          merge-multiple: true
          path: dist
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Publish Python package to PyPI
        run: |
          pip install maturin
          maturin upload --username __token__ --password "$MATURIN_PYPI_TOKEN" dist/*