Skip to content

Commit 6694688

Browse files
authored
Merge pull request #407 from sapcc/goreleaser-select-binary
[goreleaser] allow selection of builds[].binary via `binaryName` option
2 parents dfd6f25 + 5491810 commit 6694688

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ If `goReleaser.createConfig` is set to true or it is unset but the release GitHu
297297

298298
The `format` option can be used to only upload binaries. It corresponds to the upstream archives[].format option. See <https://goreleaser.com/customization/archive/> for more details.
299299

300-
The `binaryName` option can be used to change the name of the compiled binaries. It corresponds to the upstream builds[].binary option. This is only really useful when format is set to binary. It defaults to name of the first entry in the binaries option.
300+
The `binaryName` option allows you to change the name of the compiled binary or select the binary to be released. It aligns with the upstream builds[].binary option. This feature is only useful when the format is set to binary. By default, it uses the name of the first entry in the binaries option. If this name matches a predefined builds[].binary name, only that binary will be included.
301301

302302
The `nameTemplate` option can be used to change the name of uploaded release artefacts. It corresponds to the upstream archives[].name_template option.
303303

internal/goreleaser/goreleaser.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ func RenderConfig(cfg core.Configuration) {
4545
}
4646
}
4747

48-
binaryName := cfg.Binaries[0].Name
48+
binary := cfg.Binaries[0]
49+
for _, bin := range cfg.Binaries {
50+
if bin.Name == cfg.GoReleaser.BinaryName {
51+
binary = bin
52+
break
53+
}
54+
}
55+
binaryName := binary.Name
4956
if cfg.GoReleaser.BinaryName != "" {
5057
binaryName = cfg.GoReleaser.BinaryName
5158
}
@@ -71,9 +78,9 @@ func RenderConfig(cfg core.Configuration) {
7178
"format": cfg.GoReleaser.Format,
7279
"files": cfg.GoReleaser.Files,
7380
"binaryName": binaryName,
74-
"binName": cfg.Binaries[0].Name,
81+
"binName": binary.Name,
7582
"ldflags": cfg.Golang.LdFlags,
76-
"fromPackage": cfg.Binaries[0].FromPackage,
83+
"fromPackage": binary.FromPackage,
7784
"githubDomain": metadataURL,
7885
}))
7986
must.Succeed(util.WriteFileFromTemplate("RELEASE.md", releaseMDTemplate, map[string]any{

0 commit comments

Comments
 (0)