You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	renamed from binary_name to binary
This commit is contained in:
		
							
								
								
									
										14
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								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` | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -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) { | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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 | ||||
| 	} | ||||
|   | ||||
| @@ -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{ | ||||
|   | ||||
| @@ -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 = "." | ||||
|   | ||||
| @@ -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") | ||||
|   | ||||
| @@ -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{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user