mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-07 07:10:11 +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))
|
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
|
return build, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,12 +331,12 @@ func withOverrides(ctx *context.Context, build config.Build, target Target) (con
|
|||||||
|
|
||||||
if optsTarget == overrideTarget {
|
if optsTarget == overrideTarget {
|
||||||
dets := config.BuildDetails{
|
dets := config.BuildDetails{
|
||||||
Buildmode: build.BuildDetails.Buildmode,
|
Buildmode: build.Buildmode,
|
||||||
Ldflags: build.BuildDetails.Ldflags,
|
Ldflags: build.Ldflags,
|
||||||
Tags: build.BuildDetails.Tags,
|
Tags: build.Tags,
|
||||||
Flags: build.BuildDetails.Flags,
|
Flags: build.Flags,
|
||||||
Asmflags: build.BuildDetails.Asmflags,
|
Asmflags: build.Asmflags,
|
||||||
Gcflags: build.BuildDetails.Gcflags,
|
Gcflags: build.Gcflags,
|
||||||
}
|
}
|
||||||
if err := mergo.Merge(&dets, o.BuildDetails, mergo.WithOverride); err != nil {
|
if err := mergo.Merge(&dets, o.BuildDetails, mergo.WithOverride); err != nil {
|
||||||
return build.BuildDetails, err
|
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()
|
dets.Env = context.ToEnv(append(build.Env, o.BuildDetails.Env...)).Strings()
|
||||||
log.WithField("details", dets).Infof("overridden build details for %s", optsTarget)
|
log.WithField("details", dets).Infof("overridden build details for %s", optsTarget)
|
||||||
return dets, nil
|
return dets, nil
|
||||||
|
} else {
|
||||||
|
log.Debugf("targets don't match: %s != %s", optsTarget, overrideTarget)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,8 +526,8 @@ type Build struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BuildDetailsOverride struct {
|
type BuildDetailsOverride struct {
|
||||||
Goos string `yaml:"goos,omitempty" json:"goos,omitempty"`
|
Goos string `yaml:"goos" json:"goos"`
|
||||||
Goarch string `yaml:"goarch,omitempty" json:"goarch,omitempty"`
|
Goarch string `yaml:"goarch" json:"goarch"`
|
||||||
Goamd64 string `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
|
Goamd64 string `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
|
||||||
Go386 string `yaml:"go386,omitempty" json:"go386,omitempty"`
|
Go386 string `yaml:"go386,omitempty" json:"go386,omitempty"`
|
||||||
Goarm64 string `yaml:"goarm64,omitempty" json:"goarm64,omitempty"`
|
Goarm64 string `yaml:"goarm64,omitempty" json:"goarm64,omitempty"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user