mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-01 13:07:49 +02:00
fixed name_template version vs tag issue
This commit is contained in:
parent
744e7ec465
commit
a988b704ed
@ -222,7 +222,8 @@ archive:
|
|||||||
# This is parsed with Golang template engine and the following variables
|
# This is parsed with Golang template engine and the following variables
|
||||||
# are available:
|
# are available:
|
||||||
# - Binary
|
# - Binary
|
||||||
# - Version
|
# - Tag
|
||||||
|
# - Version (Tag with the `v` prefix stripped)
|
||||||
# - Os
|
# - Os
|
||||||
# - Arch
|
# - Arch
|
||||||
# The default is `{{.Binary}}_{{.Os}}_{{.Arch}}`
|
# The default is `{{.Binary}}_{{.Os}}_{{.Arch}}`
|
||||||
|
@ -11,6 +11,7 @@ type nameData struct {
|
|||||||
Os string
|
Os string
|
||||||
Arch string
|
Arch string
|
||||||
Version string
|
Version string
|
||||||
|
Tag string
|
||||||
Binary string
|
Binary string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +19,8 @@ func nameFor(ctx *context.Context, goos, goarch string) (string, error) {
|
|||||||
var data = nameData{
|
var data = nameData{
|
||||||
Os: replace(ctx.Config.Archive.Replacements, goos),
|
Os: replace(ctx.Config.Archive.Replacements, goos),
|
||||||
Arch: replace(ctx.Config.Archive.Replacements, goarch),
|
Arch: replace(ctx.Config.Archive.Replacements, goarch),
|
||||||
Version: ctx.Git.CurrentTag,
|
Version: ctx.Version,
|
||||||
|
Tag: ctx.Git.CurrentTag,
|
||||||
Binary: ctx.Config.Build.Binary,
|
Binary: ctx.Config.Build.Binary,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ func TestNameFor(t *testing.T) {
|
|||||||
|
|
||||||
var config = config.Project{
|
var config = config.Project{
|
||||||
Archive: config.Archive{
|
Archive: config.Archive{
|
||||||
NameTemplate: "{{.Binary}}_{{.Os}}_{{.Arch}}_{{.Version}}",
|
NameTemplate: "{{.Binary}}_{{.Os}}_{{.Arch}}_{{.Tag}}_{{.Version}}",
|
||||||
Replacements: map[string]string{
|
Replacements: map[string]string{
|
||||||
"darwin": "Darwin",
|
"darwin": "Darwin",
|
||||||
"amd64": "x86_64",
|
"amd64": "x86_64",
|
||||||
@ -33,6 +33,7 @@ func TestNameFor(t *testing.T) {
|
|||||||
}
|
}
|
||||||
var ctx = &context.Context{
|
var ctx = &context.Context{
|
||||||
Config: config,
|
Config: config,
|
||||||
|
Version: "1.2.3",
|
||||||
Git: context.GitInfo{
|
Git: context.GitInfo{
|
||||||
CurrentTag: "v1.2.3",
|
CurrentTag: "v1.2.3",
|
||||||
},
|
},
|
||||||
@ -40,7 +41,7 @@ func TestNameFor(t *testing.T) {
|
|||||||
|
|
||||||
name, err := nameFor(ctx, "darwin", "amd64")
|
name, err := nameFor(ctx, "darwin", "amd64")
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal("test_Darwin_x86_64_v1.2.3", name)
|
assert.Equal("test_Darwin_x86_64_v1.2.3_1.2.3", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidNameTemplate(t *testing.T) {
|
func TestInvalidNameTemplate(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user