name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2
      # `tests/go_build_smoke.rs` renders a real Go fixture and runs
      # gofmt/go vet/go build/golangci-lint against it as part of `cargo
      # test` below (same as the `test` job in ci.yml), so this job needs
      # the Go toolchain and golangci-lint on PATH too.
      # `cache: false` — see ci.yml's identical setup-go step for why.
      - uses: actions/setup-go@v6
        with:
          go-version: "1.26"
          cache: false
      - name: Install golangci-lint
        run: |
          go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.0
          echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
      - run: cargo fmt --check
      - run: cargo clippy --all-targets -- -D warnings
      - run: cargo test
      - run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
      # The Homebrew tap mentioned in REQ-1.1.4 ("brew install
      # guercheLE/tap/mcpify") is a separate, still-to-be-created repo
      # (homebrew-tap) that this workflow would push a formula update to
      # once it exists — out of scope for mcpify's own v1 code.
