Skip to content

Commit 68084e1

Browse files
jamietannachristophwitzko
authored andcommitted
feat: surface environment variable to indicate Change level
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.
1 parent bd646a8 commit 68084e1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/hooks/goreleaser.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ func (gr *GoReleaser) Success(shConfig *hooks.SuccessHookConfig) error {
8989
ctx.PreRelease = gr.prerelease
9090
ctx.Config.Release.Draft = false // always disable drafts
9191

92+
// make it possible for Goreleaser templates to understand whether the changes introduce major/minor/patch changes, so they can present that information to the user
93+
ctx.Env["GOSEMREL_MAJOR"] = ""
94+
ctx.Env["GOSEMREL_MINOR"] = ""
95+
ctx.Env["GOSEMREL_PATCH"] = ""
96+
for _, c := range shConfig.Commits {
97+
if c.Change.Major {
98+
ctx.Env["GOSEMREL_MAJOR"] = "true"
99+
}
100+
if c.Change.Minor {
101+
ctx.Env["GOSEMREL_MINOR"] = "true"
102+
}
103+
if c.Change.Patch {
104+
ctx.Env["GOSEMREL_PATCH"] = "true"
105+
}
106+
}
107+
92108
for _, pipe := range pipeline.Pipeline {
93109
if _, ok := pipe.(git.Pipe); ok {
94110
log.Info("skipping git pipe")

0 commit comments

Comments
 (0)