Skip to content

Commit

Permalink
feat: surface environment variable to indicate Change level
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jamietanna authored and christophwitzko committed Jan 18, 2024
1 parent bd646a8 commit 68084e1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/hooks/goreleaser.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ func (gr *GoReleaser) Success(shConfig *hooks.SuccessHookConfig) error {
ctx.PreRelease = gr.prerelease
ctx.Config.Release.Draft = false // always disable drafts

// 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
ctx.Env["GOSEMREL_MAJOR"] = ""
ctx.Env["GOSEMREL_MINOR"] = ""
ctx.Env["GOSEMREL_PATCH"] = ""
for _, c := range shConfig.Commits {
if c.Change.Major {
ctx.Env["GOSEMREL_MAJOR"] = "true"
}
if c.Change.Minor {
ctx.Env["GOSEMREL_MINOR"] = "true"
}
if c.Change.Patch {
ctx.Env["GOSEMREL_PATCH"] = "true"
}
}

for _, pipe := range pipeline.Pipeline {
if _, ok := pipe.(git.Pipe); ok {
log.Info("skipping git pipe")
Expand Down

0 comments on commit 68084e1

Please sign in to comment.