1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-20 03:59:26 +02:00

fix: do not default goos/goarch/goarm if targets is provided (#1789)

* fix: do not default goos/goarch/goarm if targets is provided

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* test: fixed

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2020-09-06 11:39:52 -03:00 committed by GitHub
parent 58cce33c0f
commit 28230b67f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 9 deletions

View File

@ -41,19 +41,19 @@ func (*Builder) WithDefaults(build config.Build) config.Build {
if build.Main == "" {
build.Main = "."
}
if len(build.Goos) == 0 {
build.Goos = []string{"linux", "darwin"}
}
if len(build.Goarch) == 0 {
build.Goarch = []string{"amd64", "386"}
}
if len(build.Goarm) == 0 {
build.Goarm = []string{"6"}
}
if len(build.Ldflags) == 0 {
build.Ldflags = []string{"-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser"}
}
if len(build.Targets) == 0 {
if len(build.Goos) == 0 {
build.Goos = []string{"linux", "darwin"}
}
if len(build.Goarch) == 0 {
build.Goarch = []string{"amd64", "386"}
}
if len(build.Goarm) == 0 {
build.Goarm = []string{"6"}
}
build.Targets = matrix(build)
}
if build.GoBinary == "" {

View File

@ -71,6 +71,21 @@ func TestWithDefaults(t *testing.T) {
},
goBinary: "go",
},
"custom targets": {
build: config.Build{
ID: "foo3",
Binary: "foo",
Targets: []string{
"linux_386",
"darwin_amd64",
},
},
targets: []string{
"linux_386",
"darwin_amd64",
},
goBinary: "go",
},
} {
t.Run(name, func(tt *testing.T) {
var config = config.Project{