1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-31 01:53:50 +02:00

fix: handle configs with no explicit targets on --single-target

closes #4411
This commit is contained in:
Carlos Alexandro Becker 2023-11-07 11:40:31 +00:00
parent 17393af9fa
commit c0b2be344f
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 13 additions and 2 deletions

View File

@ -260,8 +260,9 @@ func shouldBuild(build config.Build, goos, goarch string) bool {
return strings.HasPrefix(e, fmt.Sprintf("%s_%s", goos, goarch))
})
}
return slices.Contains(build.Goos, goos) &&
slices.Contains(build.Goarch, goarch)
return (len(build.Goos) == 0 && len(build.Goarch) == 0) ||
(slices.Contains(build.Goos, goos) &&
slices.Contains(build.Goarch, goarch))
}
func setupBuildID(ctx *context.Context, ids []string) error {

View File

@ -201,6 +201,16 @@ func TestBuildFlags(t *testing.T) {
require.Equal(t, []string{runtime.GOARCH}, result.Config.Builds[0].Goarch)
})
t.Run("default config", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Builds: []config.Build{{}},
})
require.NoError(t, setupBuildContext(ctx, opts))
require.Len(t, ctx.Config.Builds, 1)
require.Equal(t, []string{runtime.GOOS}, ctx.Config.Builds[0].Goos)
require.Equal(t, []string{runtime.GOARCH}, ctx.Config.Builds[0].Goarch)
})
t.Run("from env", func(t *testing.T) {
t.Setenv("GOOS", "linux")
t.Setenv("GOARCH", "arm64")