1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-04-11 11:42:15 +02:00

feat: Allow release notes to be used in template strings (#2566)

When using the announce feature, you might want to inform your users about the features and changes that this release brings. This change allows you to use {{ .ReleaseNotes }} in any template string, after the changelog pipeline step has been executed.
This commit is contained in:
Patrick Hahn 2021-10-07 19:19:19 +02:00 committed by GitHub
parent d32454e279
commit e64b2cd8da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 0 deletions

View File

@ -46,6 +46,7 @@ const (
date = "Date"
timestamp = "Timestamp"
modulePath = "ModulePath"
releaseNotes = "ReleaseNotes"
// artifact-only keys.
osKey = "Os"
@ -90,6 +91,7 @@ func New(ctx *context.Context) *Template {
patch: ctx.Semver.Patch,
prerelease: ctx.Semver.Prerelease,
isSnapshot: ctx.Snapshot,
releaseNotes: ctx.ReleaseNotes,
},
}
}

View File

@ -32,6 +32,7 @@ func TestWithArtifact(t *testing.T) {
ctx.Git.Commit = "commit"
ctx.Git.FullCommit = "fullcommit"
ctx.Git.ShortCommit = "shortcommit"
ctx.ReleaseNotes = "test release notes"
for expect, tmpl := range map[string]string{
"bar": "{{.Env.FOO}}",
"Linux": "{{.Os}}",
@ -54,6 +55,7 @@ func TestWithArtifact(t *testing.T) {
"1.3.0": "{{.Version | incminor }}",
"v1.2.4": "{{.Tag | incpatch }}",
"1.2.4": "{{.Version | incpatch }}",
"test release notes": "{{ .ReleaseNotes }}",
} {
tmpl := tmpl
expect := expect

View File

@ -28,6 +28,7 @@ On fields that support templating, these fields are always available:
| `.Patch` | the patch part of the version (assuming `Tag` is a valid semver, else `0`) |
| `.Prerelease` | the prerelease part of the version, e.g. `beta` (assuming `Tag` is a valid semver) |
| `.RawVersion` | Major.Minor.Patch (assuming `Tag` is a valid semver, else `0.0.0`) |
| `.ReleaseNotes` | the generated release notes, available after the changelog step has been executed |
| `.IsSnapshot` | `true` if `--snapshot` is set, `false` otherwise |
| `.IsNightly` | `true` if `--nightly` is set, `false` otherwise |
| `.Env` | a map with system's environment variables |