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

feat: snapshot.name_template should use tag instead of version (#2417)

* fix: Change the init-template for snapshot.name_template

* fix: Change the default-template for snapshot.name_template

BREAKIND CHANGE: The default value of `snapshot.name_template` is changed.
This commit is contained in:
Christian Mäder
2021-08-21 15:59:15 +02:00
committed by GitHub
parent 4c399575fc
commit 757701f65c
7 changed files with 8 additions and 8 deletions

View File

@@ -5,7 +5,7 @@ before:
- go mod tidy
- ./scripts/completions.sh
snapshot:
name_template: '{{ incpatch .Tag }}-next'
name_template: '{{ incpatch .Version }}-next'
gomod:
proxy: true
builds:

View File

@@ -19,7 +19,7 @@ archives:
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Tag }}-next"
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:

View File

@@ -20,7 +20,7 @@ func (Pipe) String() string {
// Default sets the pipe defaults.
func (Pipe) Default(ctx *context.Context) error {
if ctx.Config.Snapshot.NameTemplate == "" {
ctx.Config.Snapshot.NameTemplate = "{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}"
ctx.Config.Snapshot.NameTemplate = "{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}"
}
return nil
}

View File

@@ -20,7 +20,7 @@ func TestDefault(t *testing.T) {
},
}
require.NoError(t, Pipe{}.Default(ctx))
require.Equal(t, "{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}", ctx.Config.Snapshot.NameTemplate)
require.Equal(t, "{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}", ctx.Config.Snapshot.NameTemplate)
}
func TestDefaultSet(t *testing.T) {

View File

@@ -29,7 +29,7 @@ archives:
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Tag }}-next"
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:

View File

@@ -16,8 +16,8 @@ snapshot:
# Note that some pipes require this to be semantic version compliant (nfpm,
# for example).
#
# Default is `{{ .Tag }}-SNAPSHOT-{{.ShortCommit}}`.
name_template: '{{ incpatch .Tag }}-devel'
# Default is `{{ .Version }}-SNAPSHOT-{{.ShortCommit}}`.
name_template: '{{ incpatch .Version }}-devel'
```
## How it works

View File

@@ -13,7 +13,7 @@ On fields that support templating, these fields are always available:
| Key | Description |
|---------------------|------------------------------------------------------------------------------------------------------------------------------|
| `.ProjectName` | the project name |
| `.Version` | the version being released (`v` prefix stripped),<br>or `{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}` in case of snapshot release |
| `.Version` | the version being released (`v` prefix stripped),<br>or what is configured in `snapshot.name_template` in case of a snapshot release (defaults to `{{ .Version }}-SNAPSHOT-{{.ShortCommit}}`) |
| `.Branch` | the current git branch |
| `.PrefixedTag` | the current git tag prefixed with the monorepo config tag prefix (if any) |
| `.Tag` | the current git tag |