xai-openapi 0.1.1

Rust types for the xAI API (Grok models)
Documentation
name: Release

on:
  push:
    tags:
      - 'v[0-9]+.*'

env:
  CARGO_TERM_COLOR: always

jobs:
  validate:
    name: Validate Release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Extract version from tag
        id: version
        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

      - name: Verify Cargo.toml version matches tag
        run: |
          CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
          if [ "$CARGO_VERSION" != "${{ steps.version.outputs.VERSION }}" ]; then
            echo "Version mismatch: Cargo.toml has $CARGO_VERSION but tag is ${{ steps.version.outputs.VERSION }}"
            exit 1
          fi

      - name: Run full CI checks
        run: |
          cargo check --all-features
          cargo test --all-features
          cargo clippy --all-features -- -D warnings
          cargo doc --no-deps --all-features

  publish:
    name: Publish to crates.io
    needs: validate
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable

      - name: Publish
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

  release:
    name: Create GitHub Release
    needs: publish
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4

      - name: Extract version from tag
        id: version
        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

      - name: Extract changelog for this version
        id: changelog
        run: |
          # Extract changelog section for this version
          sed -n "/^## \[${{ steps.version.outputs.VERSION }}\]/,/^## \[/p" CHANGELOG.md | head -n -1 > release_notes.md
          if [ ! -s release_notes.md ]; then
            echo "No changelog entry found for version ${{ steps.version.outputs.VERSION }}"
            echo "See [CHANGELOG.md](CHANGELOG.md) for details." > release_notes.md
          fi

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          body_path: release_notes.md
          draft: false
          prerelease: ${{ contains(steps.version.outputs.VERSION, '-') }}