name: Release Go project

on:
  push:
    tags:
      - "*" # triggers only if push new tag version, like `0.8.4` or else

jobs:
  build:
    name: GoReleaser build
    runs-on: ubuntu-latest

    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v6
        with:
          fetch-depth: 0 # See: https://goreleaser.com/ci/actions/

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: "1.26"
        id: go

      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v6
        with:
          distribution: goreleaser
          # Pin to the v2 major. goreleaser-action no longer treats `latest`
          # as the absolute latest (it warns and locks to `~> v2` anyway), and
          # an unpinned `latest` risks a future goreleaser v3 silently breaking
          # releases via config-schema changes. Bump deliberately when adopting v3.
          version: "~> v2"
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}