You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-15 01:34:21 +02:00
fix: handle configs with no explicit targets on --single-target
closes #4411
This commit is contained in:
@ -260,8 +260,9 @@ func shouldBuild(build config.Build, goos, goarch string) bool {
|
|||||||
return strings.HasPrefix(e, fmt.Sprintf("%s_%s", goos, goarch))
|
return strings.HasPrefix(e, fmt.Sprintf("%s_%s", goos, goarch))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return slices.Contains(build.Goos, goos) &&
|
return (len(build.Goos) == 0 && len(build.Goarch) == 0) ||
|
||||||
slices.Contains(build.Goarch, goarch)
|
(slices.Contains(build.Goos, goos) &&
|
||||||
|
slices.Contains(build.Goarch, goarch))
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupBuildID(ctx *context.Context, ids []string) error {
|
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)
|
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.Run("from env", func(t *testing.T) {
|
||||||
t.Setenv("GOOS", "linux")
|
t.Setenv("GOOS", "linux")
|
||||||
t.Setenv("GOARCH", "arm64")
|
t.Setenv("GOARCH", "arm64")
|
||||||
|
Reference in New Issue
Block a user