name: Release on: push: tags: ["v*"] workflow_dispatch: inputs: tag: description: Git tag to release (e.g. v0.4.0) required: true type: string permissions: contents: write jobs: goreleaser: name: GoReleaser if: github.server_url == 'https://github.com' runs-on: ubuntu-latest steps: # Always clone default branch first. workflow_dispatch often races with # tag creation; fetching refs/tags/X before it exists fails checkout. # Retry fetch, then check out the tag. - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Checkout release tag env: TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} run: | set -euo pipefail echo "Releasing tag: $TAG" for i in 1 2 3 4 5 6; do if git fetch --force origin "refs/tags/${TAG}:refs/tags/${TAG}"; then break fi echo "tag $TAG not visible yet (attempt $i); sleeping…" sleep 10 done git rev-parse "refs/tags/${TAG}" git checkout --force "refs/tags/${TAG}" - name: Set up Go uses: actions/setup-go@v5 with: go-version: stable cache: true - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: "~> v2" args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}