mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-13 11:50:34 +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:
parent
d32454e279
commit
e64b2cd8da
@ -46,6 +46,7 @@ const (
|
|||||||
date = "Date"
|
date = "Date"
|
||||||
timestamp = "Timestamp"
|
timestamp = "Timestamp"
|
||||||
modulePath = "ModulePath"
|
modulePath = "ModulePath"
|
||||||
|
releaseNotes = "ReleaseNotes"
|
||||||
|
|
||||||
// artifact-only keys.
|
// artifact-only keys.
|
||||||
osKey = "Os"
|
osKey = "Os"
|
||||||
@ -90,6 +91,7 @@ func New(ctx *context.Context) *Template {
|
|||||||
patch: ctx.Semver.Patch,
|
patch: ctx.Semver.Patch,
|
||||||
prerelease: ctx.Semver.Prerelease,
|
prerelease: ctx.Semver.Prerelease,
|
||||||
isSnapshot: ctx.Snapshot,
|
isSnapshot: ctx.Snapshot,
|
||||||
|
releaseNotes: ctx.ReleaseNotes,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ func TestWithArtifact(t *testing.T) {
|
|||||||
ctx.Git.Commit = "commit"
|
ctx.Git.Commit = "commit"
|
||||||
ctx.Git.FullCommit = "fullcommit"
|
ctx.Git.FullCommit = "fullcommit"
|
||||||
ctx.Git.ShortCommit = "shortcommit"
|
ctx.Git.ShortCommit = "shortcommit"
|
||||||
|
ctx.ReleaseNotes = "test release notes"
|
||||||
for expect, tmpl := range map[string]string{
|
for expect, tmpl := range map[string]string{
|
||||||
"bar": "{{.Env.FOO}}",
|
"bar": "{{.Env.FOO}}",
|
||||||
"Linux": "{{.Os}}",
|
"Linux": "{{.Os}}",
|
||||||
@ -54,6 +55,7 @@ func TestWithArtifact(t *testing.T) {
|
|||||||
"1.3.0": "{{.Version | incminor }}",
|
"1.3.0": "{{.Version | incminor }}",
|
||||||
"v1.2.4": "{{.Tag | incpatch }}",
|
"v1.2.4": "{{.Tag | incpatch }}",
|
||||||
"1.2.4": "{{.Version | incpatch }}",
|
"1.2.4": "{{.Version | incpatch }}",
|
||||||
|
"test release notes": "{{ .ReleaseNotes }}",
|
||||||
} {
|
} {
|
||||||
tmpl := tmpl
|
tmpl := tmpl
|
||||||
expect := expect
|
expect := expect
|
||||||
|
@ -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`) |
|
| `.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) |
|
| `.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`) |
|
| `.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 |
|
| `.IsSnapshot` | `true` if `--snapshot` is set, `false` otherwise |
|
||||||
| `.IsNightly` | `true` if `--nightly` is set, `false` otherwise |
|
| `.IsNightly` | `true` if `--nightly` is set, `false` otherwise |
|
||||||
| `.Env` | a map with system's environment variables |
|
| `.Env` | a map with system's environment variables |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user