mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +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
|
||||
# are available:
|
||||
# - Binary
|
||||
# - Version
|
||||
# - Tag
|
||||
# - Version (Tag with the `v` prefix stripped)
|
||||
# - Os
|
||||
# - Arch
|
||||
# The default is `{{.Binary}}_{{.Os}}_{{.Arch}}`
|
||||
|
@ -11,6 +11,7 @@ type nameData struct {
|
||||
Os string
|
||||
Arch string
|
||||
Version string
|
||||
Tag string
|
||||
Binary string
|
||||
}
|
||||
|
||||
@ -18,7 +19,8 @@ func nameFor(ctx *context.Context, goos, goarch string) (string, error) {
|
||||
var data = nameData{
|
||||
Os: replace(ctx.Config.Archive.Replacements, goos),
|
||||
Arch: replace(ctx.Config.Archive.Replacements, goarch),
|
||||
Version: ctx.Git.CurrentTag,
|
||||
Version: ctx.Version,
|
||||
Tag: ctx.Git.CurrentTag,
|
||||
Binary: ctx.Config.Build.Binary,
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ func TestNameFor(t *testing.T) {
|
||||
|
||||
var config = config.Project{
|
||||
Archive: config.Archive{
|
||||
NameTemplate: "{{.Binary}}_{{.Os}}_{{.Arch}}_{{.Version}}",
|
||||
NameTemplate: "{{.Binary}}_{{.Os}}_{{.Arch}}_{{.Tag}}_{{.Version}}",
|
||||
Replacements: map[string]string{
|
||||
"darwin": "Darwin",
|
||||
"amd64": "x86_64",
|
||||
@ -32,7 +32,8 @@ func TestNameFor(t *testing.T) {
|
||||
},
|
||||
}
|
||||
var ctx = &context.Context{
|
||||
Config: config,
|
||||
Config: config,
|
||||
Version: "1.2.3",
|
||||
Git: context.GitInfo{
|
||||
CurrentTag: "v1.2.3",
|
||||
},
|
||||
@ -40,7 +41,7 @@ func TestNameFor(t *testing.T) {
|
||||
|
||||
name, err := nameFor(ctx, "darwin", "amd64")
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user