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:
parent
17393af9fa
commit
c0b2be344f
@ -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 {
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user