name: Release on: push: tags: - 'v*' jobs: goreleaser: name: Publish the release with GoReleaser runs-on: ubuntu-latest if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 # The runner's checkout does not reliably fetch tags, and goreleaser # needs the previous tag to list the commits since it. - name: Fetch tags run: git fetch --force --tags # Releases come from main only. - name: Verify the tag is on main run: | git fetch origin +refs/heads/main:refs/remotes/origin/main if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then echo "Tag $GITHUB_REF_NAME is not on main; refusing to release." exit 1 fi - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: go.mod # Releases are built with the Go release go.mod names: its toolchain line # if it has one, else its go line. Fail if any other Go is running. - name: Check the Go toolchain run: | want="$(sed -n 's/^toolchain //p' go.mod)" [ -n "$want" ] || want="go$(sed -n 's/^go //p' go.mod)" have="$(go env GOVERSION)" echo "go.mod names: $want; running: $have" [ "$have" = "$want" ] # prerelease: auto in .goreleaser.yaml publishes vX.Y.Z-rc.N as a # prerelease, so it never becomes the latest release. - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser # Pinned so that re-running a tag uses the same goreleaser. Same # pin as the config check in test.yml. version: '2.20.3' args: release --clean env: GITEA_TOKEN: ${{ secrets.TOKEN_GITEA }} GORELEASER_FORCE_TOKEN: gitea # The tag that triggered this run. Left to itself, goreleaser takes # the highest-sorting tag on the commit, and vX.Y.Z-rc.N sorts # above vX.Y.Z. GORELEASER_CURRENT_TAG: ${{ github.ref_name }} # Optional default Sentry DSN baked into release binaries. SENTRY_DSN: ${{ secrets.SENTRY_DSN }}