How to Use GoReleaser to Release Go Binaries

Cli
Automate Go binary releases by adding a GitHub Actions workflow that runs GoReleaser on new tags.

Use GoReleaser by adding a GitHub Actions workflow that triggers on tags and runs the release --clean command.

name: Goreleaser
on:
  push:
    tags:
      - "*"
permissions:
  contents: write
jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - name: Set up Go
        uses: actions/setup-go@v6
        with:
          go-version: "^1"
      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v7
        with:
          distribution: goreleaser
          version: latest
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Trigger Go module reindex (pkg.go.dev)
        run: |
          curl -sSf "https://proxy.golang.org/github.com/${GITHUB_REPOSITORY,,}/@v/${GITHUB_REF_NAME}.info"

Create this file at .github/workflows/goreleaser.yml, then push a new tag (e.g., git tag v1.0.0 && git push origin v1.0.0) to trigger the release.