release: prepare manifest inside GoReleaser lifecycle#24
Merged
Conversation
There was a problem hiding this comment.
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 --writeandwfctl plugin validate-contract --for-publishinto.goreleaser.ymlbefore.hooks. - Update the release workflow to keep the repo clean before GoReleaser starts, and provide
WFCTL_BINto 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.
| - go mod tidy | ||
| - go test ./... | ||
| - go run ./cmd/release-prep --tag "{{ .Tag }}" --write | ||
| - "{{ .Env.WFCTL_BIN }} plugin validate-contract --for-publish --tag {{ .Tag }} ." |
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) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #23 after the first
v0.1.12tag run failed in GoReleaser.Root cause
The release workflow ran
go run ./cmd/release-prep --writebeforegoreleaser release. That intentionally changed trackedplugin.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
.goreleaser.ymlbeforehookswfctlpath to GoReleaser asWFCTL_BINVerification
GOWORK=off go test ./... -race -count=1GOWORK=off go run ./cmd/release-prepGOWORK=off go vet ./...actionlint .github/workflows/*.ymlGOWORK=off go run github.com/goreleaser/goreleaser/v2@v2.16.0 checkgit diff --check