From bd0cb434015ada8152945edba1d70fe9f0cee71f Mon Sep 17 00:00:00 2001 From: Matt Trachier Date: Fri, 19 Sep 2025 23:17:15 -0500 Subject: [PATCH] fix: goreleaser tag race condition (#188) Signed-off-by: matttrach --- .github/workflows/release-candidate.yml | 2 +- .github/workflows/release.yml | 4 +- .goreleaser.yml | 46 ++++++++++-------- .goreleaser_rc.yml | 62 +++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 23 deletions(-) create mode 100644 .goreleaser_rc.yml diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index c8772c4..ad4e586 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -74,7 +74,7 @@ jobs: - name: Run GoReleaser uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 https://github.com/goreleaser/goreleaser-action with: - args: release --clean + args: release --clean --config .goreleaser_rc.yml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GPG_KEY_ID: ${{ env.GPG_KEY_ID }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a85904..1b34133 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -129,9 +129,9 @@ jobs: echo "${GPG_KEY}" | gpg --import --batch > /dev/null || { echo "Failed to import GPG key"; exit 1; } - name: Run GoReleaser if: steps.release-please.outputs.version - uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 + uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 https://github.com/goreleaser/goreleaser-action with: - args: release --clean + args: release --clean --config .goreleaser.yml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GPG_KEY_ID: ${{ env.GPG_KEY_ID }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 4468012..a1e94e1 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -6,27 +6,33 @@ version: 2 before: hooks: - go mod tidy +git: + ignore_tags: + - "*rc*" builds: -- env: - # goreleaser does not work with CGO, it could also complicate - # usage by users in CI/CD systems like HCP Terraform where - # they are unable to install libraries. - - CGO_ENABLED=0 - mod_timestamp: '{{ .CommitTimestamp }}' - flags: - - -trimpath - ldflags: - - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' - goos: - - freebsd - - windows - - linux - - darwin - goarch: - - amd64 - - arm - - arm64 - binary: '{{ .ProjectName }}_v{{ .Version }}' + - binary: '{{ .ProjectName }}_v{{ .Version }}' + env: + # goreleaser does not work with CGO, it could also complicate + # usage by users in CI/CD systems like HCP Terraform where + # they are unable to install libraries. + - CGO_ENABLED=0 + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - -trimpath + ldflags: + - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' + goos: + - freebsd + - windows + - linux + - darwin + goarch: + - amd64 + - arm + - arm64 + ignore: + - goos: windows + goarch: arm archives: - formats: [ 'zip' ] name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' diff --git a/.goreleaser_rc.yml b/.goreleaser_rc.yml new file mode 100644 index 0000000..7296a41 --- /dev/null +++ b/.goreleaser_rc.yml @@ -0,0 +1,62 @@ + + +# https://goreleaser.com for documentation + +version: 2 +before: + hooks: + - go mod tidy +builds: + - binary: '{{ .ProjectName }}_v{{ .Version }}' + env: + # goreleaser does not work with CGO, it could also complicate + # usage by users in CI/CD systems like HCP Terraform where + # they are unable to install libraries. + - CGO_ENABLED=0 + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - -trimpath + ldflags: + - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' + goos: + - freebsd + - windows + - linux + - darwin + goarch: + - amd64 + - arm + - arm64 + ignore: + - goos: windows + goarch: arm +archives: + - formats: [ 'zip' ] + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' +checksum: + extra_files: + - glob: 'terraform-registry-manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' + algorithm: sha256 +signs: + - artifacts: checksum + args: + - "--detach-sig" + - "--pinentry-mode" + - "loopback" + - "--passphrase" + - "{{ .Env.GPG_PASSPHRASE }}" + - "--local-user" + - "{{ .Env.GPG_KEY_ID }}" + - "--output" + - "${signature}" + - "--sign" + - "${artifact}" +release: + extra_files: + - glob: 'terraform-registry-manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' + prerelease: auto +changelog: + disable: true