Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Making it clear to goreleaser whether there are breaking changes #5

Closed
jamietanna opened this issue Jan 17, 2024 · 4 comments · Fixed by #6
Closed

Question: Making it clear to goreleaser whether there are breaking changes #5

jamietanna opened this issue Jan 17, 2024 · 4 comments · Fixed by #6

Comments

@jamietanna
Copy link
Contributor

Related to / duplicate of go-semantic-release/semantic-release#171

How would it be possible to detect something within the release notes / a breaking change introduced? It appears that the {{ .ReleaseNotes }} variable for goreleaser has no value when using this hook.

@jamietanna
Copy link
Contributor Author

jamietanna commented Jan 17, 2024

May be bale to do something like:

diff --git pkg/hooks/goreleaser.go pkg/hooks/goreleaser.go
index 8308c68..550c62e 100644
--- pkg/hooks/goreleaser.go
+++ pkg/hooks/goreleaser.go
@@ -67,6 +67,15 @@ func (gr *GoReleaser) Success(shConfig *hooks.SuccessHookConfig) error {
 		FullCommit:  currentSha,
 		ShortCommit: currentSha,
 	}
+	isBreaking := false
+
+	for _, c := range shConfig.GetCommits() {
+		if c.Change.Major {
+			isBreaking = true
+			break
+		}
+	}
+	// TODO: set environment variable
 
 	repo := config.Repo{
 		Owner: shConfig.RepoInfo.Owner,
@@ -88,6 +97,7 @@ func (gr *GoReleaser) Success(shConfig *hooks.SuccessHookConfig) error {
 	ctx.Config.Release.NameTemplate = ctx.Git.CurrentTag
 	ctx.PreRelease = gr.prerelease
 	ctx.Config.Release.Draft = false // always disable drafts
+	ctx.Env["GOSEMREL_BREAKING"] = fmt.Sprintf("%t", isBreaking)
 
 	for _, pipe := range pipeline.Pipeline {
 		if _, ok := pipe.(git.Pipe); ok {

@jamietanna
Copy link
Contributor Author

jamietanna commented Jan 17, 2024

This may not work if it's a v0 project, though 🤔

jamietanna added a commit to jamietanna/hooks-goreleaser that referenced this issue Jan 18, 2024
As noted in go-semantic-release#5, it would be useful for Goreleaser templates to be able
to understand the different semver changes introduced in the release.

This exposes a variable if the change is detected, allowing a consumer
to use something like the below to conditionally handle the presence
(and non-zero contents), such as:

    {{ if .Env.GOSEMREL_MAJOR }} ... {{ end }}

Closes go-semantic-release#5.
christophwitzko pushed a commit that referenced this issue Jan 18, 2024
As noted in #5, it would be useful for Goreleaser templates to be able
to understand the different semver changes introduced in the release.

This exposes a variable if the change is detected, allowing a consumer
to use something like the below to conditionally handle the presence
(and non-zero contents), such as:

    {{ if .Env.GOSEMREL_MAJOR }} ... {{ end }}

Closes #5.
@christophwitzko
Copy link
Member

Thanks again for taking care of this. ☺️

@jamietanna
Copy link
Contributor Author

You're welcome, thanks for a speedy release 🚀

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 a pull request may close this issue.

2 participants