1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-09-16 09:26:52 +02:00

renamed from binary_name to binary

This commit is contained in:
Carlos Alexandro Becker
2017-03-22 21:06:37 -03:00
parent 45ec67efb3
commit b3fa5cfc19
10 changed files with 46 additions and 41 deletions

View File

@@ -57,7 +57,7 @@ By default GoReleaser will build the **main.go** file located in your current di
# goreleaser.yml # goreleaser.yml
# Build customization # Build customization
build: build:
binary_name: drum-roll binary: drum-roll
goos: goos:
- windows - windows
- darwin - 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`. 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. 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. 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 customization
build: build:
main: main.go main: main.go
binary_name: drum-roll binary: drum-roll
goos: goos:
- windows - windows
- darwin - darwin
@@ -170,7 +170,7 @@ build:
# Name of the binary. # Name of the binary.
# Default is the name of the project directory. # Default is the name of the project directory.
binary_name: program binary: program
# Custom build tags. # Custom build tags.
# Default is empty # Default is empty
@@ -209,12 +209,12 @@ archive:
# You can change the name of the archive. # You can change the name of the 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:
# - BinaryName # - Binary
# - Version # - Version
# - Os # - Os
# - Arch # - Arch
# The default is `{{.BinaryName}}_{{.Os}}_{{.Arch}}` # The default is `{{.Binary}}_{{.Os}}_{{.Arch}}`
name_template: "{{.BinaryName}}_{{.Version}}_{{.Os}}_{{.Arch}}" name_template: "{{.Binary}}_{{.Version}}_{{.Os}}_{{.Arch}}"
# Archive format. Valid options are `tar.gz` and `zip`. # Archive format. Valid options are `tar.gz` and `zip`.
# Default is `tar.gz` # Default is `tar.gz`

View File

@@ -42,7 +42,8 @@ type Build struct {
Main string Main string
Ldflags string Ldflags string
Flags string Flags string
BinaryName string `yaml:"binary_name"` BinaryName string `yaml:"binary_name"` // deprecated
Binary string
Hooks Hooks Hooks Hooks
} }

View File

@@ -68,7 +68,7 @@ type templateData struct {
Repo config.Repo // FIXME: will not work for anything but github right now. Repo config.Repo // FIXME: will not work for anything but github right now.
Tag string Tag string
Version string Version string
BinaryName string Binary string
Caveats string Caveats string
File string File string
Format string Format string
@@ -103,7 +103,7 @@ func (Pipe) Run(ctx *context.Context) error {
} }
client := clients.GitHub(ctx) client := clients.GitHub(ctx)
path := filepath.Join( 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()) log.Println("Pushing", path, "to", ctx.Config.Brew.GitHub.String())
@@ -119,7 +119,7 @@ func (Pipe) Run(ctx *context.Context) error {
}, },
Content: out.Bytes(), Content: out.Bytes(),
Message: github.String( 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) { func doBuildFormula(data templateData) (bytes.Buffer, error) {
var out bytes.Buffer var out bytes.Buffer
tmpl, err := template.New(data.BinaryName).Parse(formula) tmpl, err := template.New(data.Binary).Parse(formula)
if err != nil { if err != nil {
return out, err return out, err
} }
@@ -201,13 +201,13 @@ func dataFor(
description = *rep.Description description = *rep.Description
} }
return templateData{ return templateData{
Name: formulaNameFor(ctx.Config.Build.BinaryName), Name: formulaNameFor(ctx.Config.Build.Binary),
Desc: description, Desc: description,
Homepage: homepage, Homepage: homepage,
Repo: ctx.Config.Release.GitHub, Repo: ctx.Config.Release.GitHub,
Tag: ctx.Git.CurrentTag, Tag: ctx.Git.CurrentTag,
Version: ctx.Version, Version: ctx.Version,
BinaryName: ctx.Config.Build.BinaryName, Binary: ctx.Config.Build.Binary,
Caveats: ctx.Config.Brew.Caveats, Caveats: ctx.Config.Brew.Caveats,
File: file, File: file,
Format: ctx.Config.Archive.Format, Format: ctx.Config.Archive.Format,

View File

@@ -20,16 +20,16 @@ func TestSimpleName(t *testing.T) {
} }
var defaultTemplateData = templateData{ var defaultTemplateData = templateData{
BinaryName: "test", Binary: "test",
Desc: "Some desc", Desc: "Some desc",
Homepage: "https://google.com", Homepage: "https://google.com",
Name: "Test", Name: "Test",
Repo: config.Repo{"caarlos0", "test"}, Repo: config.Repo{"caarlos0", "test"},
Tag: "v0.1.3", Tag: "v0.1.3",
Version: "0.1.3", Version: "0.1.3",
File: "test_Darwin_x86_64", File: "test_Darwin_x86_64",
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68", SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
Format: "tar.gz", Format: "tar.gz",
} }
func assertDefaultTemplateData(t *testing.T, formulae string) { func assertDefaultTemplateData(t *testing.T, formulae string) {

View File

@@ -41,7 +41,7 @@ func (Pipe) Run(ctx *context.Context) error {
func build(name, goos, goarch string, ctx *context.Context) error { func build(name, goos, goarch string, ctx *context.Context) error {
ldflags := ctx.Config.Build.Ldflags + " -X main.version=" + ctx.Version 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) log.Println("Building", output)
if ctx.Config.Build.Hooks.Pre != "" { if ctx.Config.Build.Hooks.Pre != "" {
cmd := strings.Fields(ctx.Config.Build.Hooks.Pre) cmd := strings.Fields(ctx.Config.Build.Hooks.Pre)

View File

@@ -8,21 +8,21 @@ import (
) )
type nameData struct { type nameData struct {
Os string Os string
Arch string Arch string
Version string Version string
BinaryName string Binary string
} }
func nameFor(ctx *context.Context, goos, goarch string) (string, error) { 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.Git.CurrentTag,
BinaryName: ctx.Config.Build.BinaryName, Binary: ctx.Config.Build.Binary,
} }
var out bytes.Buffer 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 { if err != nil {
return "", err return "", err
} }

View File

@@ -21,14 +21,14 @@ func TestNameFor(t *testing.T) {
var config = config.Project{ var config = config.Project{
Archive: config.Archive{ Archive: config.Archive{
NameTemplate: "{{.BinaryName}}_{{.Os}}_{{.Arch}}_{{.Version}}", NameTemplate: "{{.Binary}}_{{.Os}}_{{.Arch}}_{{.Version}}",
Replacements: map[string]string{ Replacements: map[string]string{
"darwin": "Darwin", "darwin": "Darwin",
"amd64": "x86_64", "amd64": "x86_64",
}, },
}, },
Build: config.Build{ Build: config.Build{
BinaryName: "test", Binary: "test",
}, },
} }
var ctx = &context.Context{ var ctx = &context.Context{

View File

@@ -33,9 +33,13 @@ func (Pipe) Run(ctx *context.Context) error {
return errors.New("failed reading repo from git: " + err.Error()) return errors.New("failed reading repo from git: " + err.Error())
} }
} }
// TODO: remove this block in next release cycle
if ctx.Config.Build.BinaryName == "" { if ctx.Config.Build.BinaryName != "" {
ctx.Config.Build.BinaryName = ctx.Config.Release.GitHub.Name 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 == "" { if ctx.Config.Build.Main == "" {
ctx.Config.Build.Main = "." ctx.Config.Build.Main = "."

View File

@@ -19,7 +19,7 @@ func TestFillBasicData(t *testing.T) {
assert.Equal("goreleaser", ctx.Config.Release.GitHub.Owner) assert.Equal("goreleaser", ctx.Config.Release.GitHub.Owner)
assert.Equal("goreleaser", ctx.Config.Release.GitHub.Name) 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(".", ctx.Config.Build.Main)
assert.Equal("tar.gz", ctx.Config.Archive.Format) assert.Equal("tar.gz", ctx.Config.Archive.Format)
assert.Contains(ctx.Config.Build.Goos, "darwin") assert.Contains(ctx.Config.Build.Goos, "darwin")

View File

@@ -56,7 +56,7 @@ func (Pipe) Run(ctx *context.Context) error {
func create(ctx *context.Context, format, archive, arch string) error { func create(ctx *context.Context, format, archive, arch string) error {
var path = filepath.Join("dist", archive) var path = filepath.Join("dist", archive)
var file = path + ".deb" var file = path + ".deb"
var name = ctx.Config.Build.BinaryName var name = ctx.Config.Build.Binary
log.Println("Creating", file) log.Println("Creating", file)
var options = []string{ var options = []string{