From b3fa5cfc192c17fa3cafdcd99d72203c37f3ac99 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 22 Mar 2017 21:06:37 -0300 Subject: [PATCH] renamed from binary_name to binary --- README.md | 14 +++++++------- config/config.go | 3 ++- pipeline/brew/brew.go | 12 ++++++------ pipeline/brew/brew_test.go | 20 ++++++++++---------- pipeline/build/build.go | 2 +- pipeline/build/name.go | 18 +++++++++--------- pipeline/build/name_test.go | 4 ++-- pipeline/defaults/defaults.go | 10 +++++++--- pipeline/defaults/defaults_test.go | 2 +- pipeline/fpm/fpm.go | 2 +- 10 files changed, 46 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 6ba46e991..91f2c4413 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ By default GoReleaser will build the **main.go** file located in your current di # goreleaser.yml # Build customization build: - binary_name: drum-roll + binary: drum-roll goos: - windows - darwin @@ -68,7 +68,7 @@ build: This configuration specifies the build operating systems to Windows, Linux and MacOS using 64bit architecture, the name of the binaries is `drum-roll`. -GoReleaser will then archive the result binaries of each Os/Arch into a separate file. The default format is `{{.BinaryName}}_{{.Os}}_{{.Arch}}`. +GoReleaser will then archive the result binaries of each Os/Arch into a separate file. The default format is `{{.Binary}}_{{.Os}}_{{.Arch}}`. You can change the archives name and format. You can also replace the OS and the Architecture with your own. Another useful feature is to add files to archives, this is very useful for integrating assets like resource files. @@ -77,7 +77,7 @@ Another useful feature is to add files to archives, this is very useful for inte # Build customization build: main: main.go - binary_name: drum-roll + binary: drum-roll goos: - windows - darwin @@ -170,7 +170,7 @@ build: # Name of the binary. # Default is the name of the project directory. - binary_name: program + binary: program # Custom build tags. # Default is empty @@ -209,12 +209,12 @@ archive: # You can change the name of the archive. # This is parsed with Golang template engine and the following variables # are available: - # - BinaryName + # - Binary # - Version # - Os # - Arch - # The default is `{{.BinaryName}}_{{.Os}}_{{.Arch}}` - name_template: "{{.BinaryName}}_{{.Version}}_{{.Os}}_{{.Arch}}" + # The default is `{{.Binary}}_{{.Os}}_{{.Arch}}` + name_template: "{{.Binary}}_{{.Version}}_{{.Os}}_{{.Arch}}" # Archive format. Valid options are `tar.gz` and `zip`. # Default is `tar.gz` diff --git a/config/config.go b/config/config.go index 44431cb21..b1eab7b92 100644 --- a/config/config.go +++ b/config/config.go @@ -42,7 +42,8 @@ type Build struct { Main string Ldflags string Flags string - BinaryName string `yaml:"binary_name"` + BinaryName string `yaml:"binary_name"` // deprecated + Binary string Hooks Hooks } diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index 5457ab409..8c62c677c 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -68,7 +68,7 @@ type templateData struct { Repo config.Repo // FIXME: will not work for anything but github right now. Tag string Version string - BinaryName string + Binary string Caveats string File string Format string @@ -103,7 +103,7 @@ func (Pipe) Run(ctx *context.Context) error { } client := clients.GitHub(ctx) path := filepath.Join( - ctx.Config.Brew.Folder, ctx.Config.Build.BinaryName+".rb", + ctx.Config.Brew.Folder, ctx.Config.Build.Binary+".rb", ) log.Println("Pushing", path, "to", ctx.Config.Brew.GitHub.String()) @@ -119,7 +119,7 @@ func (Pipe) Run(ctx *context.Context) error { }, Content: out.Bytes(), Message: github.String( - ctx.Config.Build.BinaryName + " version " + ctx.Git.CurrentTag, + ctx.Config.Build.Binary + " version " + ctx.Git.CurrentTag, ), } @@ -161,7 +161,7 @@ func buildFormula(ctx *context.Context, client *github.Client) (bytes.Buffer, er func doBuildFormula(data templateData) (bytes.Buffer, error) { var out bytes.Buffer - tmpl, err := template.New(data.BinaryName).Parse(formula) + tmpl, err := template.New(data.Binary).Parse(formula) if err != nil { return out, err } @@ -201,13 +201,13 @@ func dataFor( description = *rep.Description } return templateData{ - Name: formulaNameFor(ctx.Config.Build.BinaryName), + Name: formulaNameFor(ctx.Config.Build.Binary), Desc: description, Homepage: homepage, Repo: ctx.Config.Release.GitHub, Tag: ctx.Git.CurrentTag, Version: ctx.Version, - BinaryName: ctx.Config.Build.BinaryName, + Binary: ctx.Config.Build.Binary, Caveats: ctx.Config.Brew.Caveats, File: file, Format: ctx.Config.Archive.Format, diff --git a/pipeline/brew/brew_test.go b/pipeline/brew/brew_test.go index 031c7c787..506fd95f6 100644 --- a/pipeline/brew/brew_test.go +++ b/pipeline/brew/brew_test.go @@ -20,16 +20,16 @@ func TestSimpleName(t *testing.T) { } var defaultTemplateData = templateData{ - BinaryName: "test", - Desc: "Some desc", - Homepage: "https://google.com", - Name: "Test", - Repo: config.Repo{"caarlos0", "test"}, - Tag: "v0.1.3", - Version: "0.1.3", - File: "test_Darwin_x86_64", - SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68", - Format: "tar.gz", + Binary: "test", + Desc: "Some desc", + Homepage: "https://google.com", + Name: "Test", + Repo: config.Repo{"caarlos0", "test"}, + Tag: "v0.1.3", + Version: "0.1.3", + File: "test_Darwin_x86_64", + SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68", + Format: "tar.gz", } func assertDefaultTemplateData(t *testing.T, formulae string) { diff --git a/pipeline/build/build.go b/pipeline/build/build.go index e1aa16ee2..06164eb2c 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -41,7 +41,7 @@ func (Pipe) Run(ctx *context.Context) error { func build(name, goos, goarch string, ctx *context.Context) error { ldflags := ctx.Config.Build.Ldflags + " -X main.version=" + ctx.Version - output := "dist/" + name + "/" + ctx.Config.Build.BinaryName + extFor(goos) + output := "dist/" + name + "/" + ctx.Config.Build.Binary + extFor(goos) log.Println("Building", output) if ctx.Config.Build.Hooks.Pre != "" { cmd := strings.Fields(ctx.Config.Build.Hooks.Pre) diff --git a/pipeline/build/name.go b/pipeline/build/name.go index 135e175be..b1384aa4a 100644 --- a/pipeline/build/name.go +++ b/pipeline/build/name.go @@ -8,21 +8,21 @@ import ( ) type nameData struct { - Os string - Arch string - Version string - BinaryName string + Os string + Arch string + Version string + Binary string } 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, - BinaryName: ctx.Config.Build.BinaryName, + Os: replace(ctx.Config.Archive.Replacements, goos), + Arch: replace(ctx.Config.Archive.Replacements, goarch), + Version: ctx.Git.CurrentTag, + Binary: ctx.Config.Build.Binary, } var out bytes.Buffer - t, err := template.New(data.BinaryName).Parse(ctx.Config.Archive.NameTemplate) + t, err := template.New(data.Binary).Parse(ctx.Config.Archive.NameTemplate) if err != nil { return "", err } diff --git a/pipeline/build/name_test.go b/pipeline/build/name_test.go index b6f5c1c81..6a38b364c 100644 --- a/pipeline/build/name_test.go +++ b/pipeline/build/name_test.go @@ -21,14 +21,14 @@ func TestNameFor(t *testing.T) { var config = config.Project{ Archive: config.Archive{ - NameTemplate: "{{.BinaryName}}_{{.Os}}_{{.Arch}}_{{.Version}}", + NameTemplate: "{{.Binary}}_{{.Os}}_{{.Arch}}_{{.Version}}", Replacements: map[string]string{ "darwin": "Darwin", "amd64": "x86_64", }, }, Build: config.Build{ - BinaryName: "test", + Binary: "test", }, } var ctx = &context.Context{ diff --git a/pipeline/defaults/defaults.go b/pipeline/defaults/defaults.go index eb1487b51..c1bf047dd 100644 --- a/pipeline/defaults/defaults.go +++ b/pipeline/defaults/defaults.go @@ -33,9 +33,13 @@ func (Pipe) Run(ctx *context.Context) error { return errors.New("failed reading repo from git: " + err.Error()) } } - - if ctx.Config.Build.BinaryName == "" { - ctx.Config.Build.BinaryName = ctx.Config.Release.GitHub.Name + // TODO: remove this block in next release cycle + if ctx.Config.Build.BinaryName != "" { + log.Println("The `build.binary_name` syntax is deprecated and will soon be removed. Please check the README for more info.") + ctx.Config.Build.Binary = ctx.Config.Build.BinaryName + } + if ctx.Config.Build.Binary == "" { + ctx.Config.Build.Binary = ctx.Config.Release.GitHub.Name } if ctx.Config.Build.Main == "" { ctx.Config.Build.Main = "." diff --git a/pipeline/defaults/defaults_test.go b/pipeline/defaults/defaults_test.go index 27bd6ed29..dee65285b 100644 --- a/pipeline/defaults/defaults_test.go +++ b/pipeline/defaults/defaults_test.go @@ -19,7 +19,7 @@ func TestFillBasicData(t *testing.T) { assert.Equal("goreleaser", ctx.Config.Release.GitHub.Owner) assert.Equal("goreleaser", ctx.Config.Release.GitHub.Name) - assert.Equal("goreleaser", ctx.Config.Build.BinaryName) + assert.Equal("goreleaser", ctx.Config.Build.Binary) assert.Equal(".", ctx.Config.Build.Main) assert.Equal("tar.gz", ctx.Config.Archive.Format) assert.Contains(ctx.Config.Build.Goos, "darwin") diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 3ea768c50..8f05e8129 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -56,7 +56,7 @@ func (Pipe) Run(ctx *context.Context) error { func create(ctx *context.Context, format, archive, arch string) error { var path = filepath.Join("dist", archive) var file = path + ".deb" - var name = ctx.Config.Build.BinaryName + var name = ctx.Config.Build.Binary log.Println("Creating", file) var options = []string{