petekstatic 0.1.5

petekStatic — the GEOMODEL layer: structural framework, grid construction, property modelling, volumetrics and static uncertainty, consolidated into one crate.
Documentation
name: release
on:
  push:
    tags: ["v*"]
  workflow_dispatch:
permissions:
  contents: read
jobs:
  gates:
    # Same rust gates as ci.yml — a tag can only publish what passes them.
    name: gates (fmt / clippy / test)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt
      - uses: Swatinem/rust-cache@v2
      - name: require v* tag
        run: |
          case "$GITHUB_REF" in
            refs/tags/v*) ;;
            *) echo "release workflow must run from a v* tag, got $GITHUB_REF" >&2; exit 1 ;;
          esac
      - name: verify tag matches Cargo.toml
        run: |
          VER=$(cargo metadata --no-deps --format-version 1 \
            | jq -r '.packages[] | select(.name=="petekstatic") | .version')
          TAG="${GITHUB_REF_NAME#v}"
          if [ "$VER" != "$TAG" ]; then
            echo "tag ${GITHUB_REF_NAME} does not match Cargo version ${VER}" >&2
            exit 1
          fi
      - name: fmt
        run: cargo fmt --all --check
      - name: clippy (warnings = errors)
        run: cargo clippy --workspace --all-targets -- -D warnings
      - name: test
        run: cargo test --workspace
  build-wheels:
    name: wheels (${{ matrix.os }}-${{ matrix.target }})
    needs: gates
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - { os: ubuntu-latest,   target: x86_64 }
          - { os: ubuntu-latest,   target: aarch64 }
          - { os: macos-latest,    target: aarch64 }
          - { os: macos-latest,    target: x86_64 }
          - { os: windows-latest,  target: x64 }
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.x" }
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist
          manylinux: auto
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-${{ matrix.os }}-${{ matrix.target }}
          path: dist
  sdist:
    name: build sdist
    needs: gates
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build sdist
        uses: PyO3/maturin-action@v1
        with:
          command: sdist
          args: --out dist
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-sdist
          path: dist
  publish-crate:
    name: crates.io
    needs: gates
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish to crates.io (skip if this version is already published)
        run: |
          VER=$(cargo metadata --no-deps --format-version 1 \
            | jq -r '.packages[] | select(.name=="petekstatic") | .version')
          if curl -fsS -H "User-Agent: petekstatic-ci" \
               "https://crates.io/api/v1/crates/petekstatic/$VER" \
               | jq -e '.version.num' >/dev/null 2>&1; then
            echo "petekstatic $VER already on crates.io; skipping publish"
          else
            cargo publish -p petekstatic --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
          fi

  publish-pypi:
    name: publish to PyPI (trusted publishing)
    needs: [gates, build-wheels, sdist]
    runs-on: ubuntu-latest
    environment: pypi
    permissions:
      id-token: write
    steps:
      - uses: actions/download-artifact@v4
        with: { pattern: wheels-*, merge-multiple: true, path: dist }
      - uses: pypa/gh-action-pypi-publish@release/v1

  github-release:
    name: GitHub Release
    needs: [publish-crate, publish-pypi]
    if: startsWith(github.ref, 'refs/tags/')
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true