mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix(build): improve build overrides handling
- jsonschema: make both goos and goarch mandatory - log.warn if any of them are empty - log.debug when it doesn't match refs #5322
This commit is contained in:
parent
0357cfecc5
commit
8f0cede737
@ -145,6 +145,13 @@ func (*Builder) WithDefaults(build config.Build) (config.Build, error) {
|
||||
}
|
||||
build.Targets = slices.Collect(maps.Keys(targets))
|
||||
}
|
||||
|
||||
for _, o := range build.BuildDetailsOverrides {
|
||||
if o.Goos == "" || o.Goarch == "" {
|
||||
log.Warn("overrides must set, at least, both 'goos' and 'goarch'")
|
||||
break
|
||||
}
|
||||
}
|
||||
return build, nil
|
||||
}
|
||||
|
||||
@ -324,12 +331,12 @@ func withOverrides(ctx *context.Context, build config.Build, target Target) (con
|
||||
|
||||
if optsTarget == overrideTarget {
|
||||
dets := config.BuildDetails{
|
||||
Buildmode: build.BuildDetails.Buildmode,
|
||||
Ldflags: build.BuildDetails.Ldflags,
|
||||
Tags: build.BuildDetails.Tags,
|
||||
Flags: build.BuildDetails.Flags,
|
||||
Asmflags: build.BuildDetails.Asmflags,
|
||||
Gcflags: build.BuildDetails.Gcflags,
|
||||
Buildmode: build.Buildmode,
|
||||
Ldflags: build.Ldflags,
|
||||
Tags: build.Tags,
|
||||
Flags: build.Flags,
|
||||
Asmflags: build.Asmflags,
|
||||
Gcflags: build.Gcflags,
|
||||
}
|
||||
if err := mergo.Merge(&dets, o.BuildDetails, mergo.WithOverride); err != nil {
|
||||
return build.BuildDetails, err
|
||||
@ -338,6 +345,8 @@ func withOverrides(ctx *context.Context, build config.Build, target Target) (con
|
||||
dets.Env = context.ToEnv(append(build.Env, o.BuildDetails.Env...)).Strings()
|
||||
log.WithField("details", dets).Infof("overridden build details for %s", optsTarget)
|
||||
return dets, nil
|
||||
} else {
|
||||
log.Debugf("targets don't match: %s != %s", optsTarget, overrideTarget)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,8 +526,8 @@ type Build struct {
|
||||
}
|
||||
|
||||
type BuildDetailsOverride struct {
|
||||
Goos string `yaml:"goos,omitempty" json:"goos,omitempty"`
|
||||
Goarch string `yaml:"goarch,omitempty" json:"goarch,omitempty"`
|
||||
Goos string `yaml:"goos" json:"goos"`
|
||||
Goarch string `yaml:"goarch" json:"goarch"`
|
||||
Goamd64 string `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
|
||||
Go386 string `yaml:"go386,omitempty" json:"go386,omitempty"`
|
||||
Goarm64 string `yaml:"goarm64,omitempty" json:"goarm64,omitempty"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user