Skip to content

release: prepare manifest inside GoReleaser lifecycle#24

Merged
intel352 merged 1 commit into
mainfrom
fix/release-prep-goreleaser-hook
Jun 6, 2026
Merged

release: prepare manifest inside GoReleaser lifecycle#24
intel352 merged 1 commit into
mainfrom
fix/release-prep-goreleaser-hook

Conversation

@intel352
Copy link
Copy Markdown
Contributor

@intel352 intel352 commented Jun 6, 2026

Follow-up to #23 after the first v0.1.12 tag run failed in GoReleaser.

Root cause

The release workflow ran go run ./cmd/release-prep --write before goreleaser release. That intentionally changed tracked plugin.json, and GoReleaser rejects dirty trees before it builds or publishes artifacts. The failed run is https://github.com/GoCodeAlone/workflow-plugin-product-capture/actions/runs/27070798168.

Summary

  • move manifest rewrite and publish contract validation into .goreleaser.yml before hooks
  • pass the installed wfctl path to GoReleaser as WFCTL_BIN
  • keep the workflow tree clean before GoReleaser starts, while still packaging the generated release manifest
  • add regression coverage for the hook ordering

Verification

  • GOWORK=off go test ./... -race -count=1
  • GOWORK=off go run ./cmd/release-prep
  • GOWORK=off go vet ./...
  • actionlint .github/workflows/*.yml
  • GOWORK=off go run github.com/goreleaser/goreleaser/v2@v2.16.0 check
  • git diff --check

Copilot AI review requested due to automatic review settings June 6, 2026 18:52
@intel352 intel352 merged commit 986861b into main Jun 6, 2026
5 checks passed
@intel352 intel352 deleted the fix/release-prep-goreleaser-hook branch June 6, 2026 18:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the GoReleaser “dirty tree” failure by moving release-manifest generation and publish-contract validation from the GitHub Actions workflow into GoReleaser’s before.hooks, while passing the installed wfctl binary path into GoReleaser via WFCTL_BIN.

Changes:

  • Move cmd/release-prep --write and wfctl plugin validate-contract --for-publish into .goreleaser.yml before.hooks.
  • Update the release workflow to keep the repo clean before GoReleaser starts, and provide WFCTL_BIN to GoReleaser via env.
  • Add/adjust regression tests to cover the new lifecycle placement.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
release_workflow_test.go Updates workflow assertions and adds coverage for GoReleaser lifecycle hooks.
.goreleaser.yml Adds before.hooks steps to rewrite plugin.json and validate publish contracts during release.
.github/workflows/release.yml Removes pre-GoReleaser manifest rewrite/validation and passes WFCTL_BIN into GoReleaser.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .goreleaser.yml
- go mod tidy
- go test ./...
- go run ./cmd/release-prep --tag "{{ .Tag }}" --write
- "{{ .Env.WFCTL_BIN }} plugin validate-contract --for-publish --tag {{ .Tag }} ."
Comment thread release_workflow_test.go
Comment on lines +41 to +55
func TestGoReleaserPreparesReleaseManifestInsideLifecycle(t *testing.T) {
data, err := os.ReadFile(".goreleaser.yml")
if err != nil {
t.Fatal(err)
}
config := string(data)
for _, want := range []string{
`go run ./cmd/release-prep --tag "{{ .Tag }}" --write`,
`"{{ .Env.WFCTL_BIN }} plugin validate-contract --for-publish --tag {{ .Tag }} ."`,
} {
if !strings.Contains(config, want) {
t.Fatalf(".goreleaser.yml missing release hook %q", want)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants