go-semantic-release / hooks-goreleaser

🚢 GoReleaser hooks plugin
MIT License
4 stars 1 forks source link

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

Closed jamietanna closed 10 months ago

jamietanna commented 10 months ago

Related to / duplicate of https://github.com/go-semantic-release/semantic-release/issues/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 commented 10 months ago

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 commented 10 months ago

~This may not work if it's a v0 project, though :thinking:~

christophwitzko commented 10 months ago

Thanks again for taking care of this. ☺️

jamietanna commented 10 months ago

You're welcome, thanks for a speedy release 🚀