1
0
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:
Carlos Alexandro Becker 2017-04-24 12:46:06 -03:00
parent 744e7ec465
commit a988b704ed
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 9 additions and 5 deletions

View File

@ -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}}`

View File

@ -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,
} }

View File

@ -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) {