mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
feat(build): templateable no_unique_dist_dir (#5115)
closes https://github.com/goreleaser/goreleaser/issues/5024 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
2d3b737d03
commit
301b193e6e
@ -198,7 +198,11 @@ func buildOptionsForTarget(ctx *context.Context, build config.Build, target stri
|
||||
|
||||
name := bin + ext
|
||||
dir := fmt.Sprintf("%s_%s", build.ID, target)
|
||||
if build.NoUniqueDistDir {
|
||||
noUnique, err := tmpl.New(ctx).Bool(build.NoUniqueDistDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if noUnique {
|
||||
dir = ""
|
||||
}
|
||||
relpath := filepath.Join(ctx.Config.Dist, dir, name)
|
||||
|
@ -623,18 +623,37 @@ func TestBuildOptionsForTarget(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "overriding dist path",
|
||||
name: "no unique dist path evals true",
|
||||
build: config.Build{
|
||||
ID: "testid",
|
||||
Binary: "distpath/{{.Os}}/{{.Arch}}/testbinary_{{.Os}}_{{.Arch}}",
|
||||
Binary: "distpath/{{.Os}}/{{.Arch}}/testbinary",
|
||||
Targets: []string{
|
||||
"linux_amd64",
|
||||
},
|
||||
NoUniqueDistDir: true,
|
||||
NoUniqueDistDir: `{{ printf "true"}}`,
|
||||
},
|
||||
expectedOpts: &api.Options{
|
||||
Name: "distpath/linux/amd64/testbinary_linux_amd64",
|
||||
Path: filepath.Join(tmpDir, "distpath", "linux", "amd64", "testbinary_linux_amd64"),
|
||||
Name: "distpath/linux/amd64/testbinary",
|
||||
Path: filepath.Join(tmpDir, "distpath", "linux", "amd64", "testbinary"),
|
||||
Target: "linux_amd64_v1",
|
||||
Goos: "linux",
|
||||
Goarch: "amd64",
|
||||
Goamd64: "v1",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no unique dist path evals false",
|
||||
build: config.Build{
|
||||
ID: "testid",
|
||||
Binary: "testbinary",
|
||||
Targets: []string{
|
||||
"linux_amd64",
|
||||
},
|
||||
NoUniqueDistDir: `{{ printf "false"}}`,
|
||||
},
|
||||
expectedOpts: &api.Options{
|
||||
Name: "testbinary",
|
||||
Path: filepath.Join(tmpDir, "testid_linux_amd64_v1", "testbinary"),
|
||||
Target: "linux_amd64_v1",
|
||||
Goos: "linux",
|
||||
Goarch: "amd64",
|
||||
|
@ -504,7 +504,7 @@ type Build struct {
|
||||
Skip string `yaml:"skip,omitempty" json:"skip,omitempty" jsonschema:"oneof_type=string;boolean"`
|
||||
GoBinary string `yaml:"gobinary,omitempty" json:"gobinary,omitempty"`
|
||||
Command string `yaml:"command,omitempty" json:"command,omitempty"`
|
||||
NoUniqueDistDir bool `yaml:"no_unique_dist_dir,omitempty" json:"no_unique_dist_dir,omitempty"`
|
||||
NoUniqueDistDir string `yaml:"no_unique_dist_dir,omitempty" json:"no_unique_dist_dir,omitempty" jsonschema:"oneof_type:string;boolean"`
|
||||
NoMainCheck bool `yaml:"no_main_check,omitempty" json:"no_main_check,omitempty"`
|
||||
UnproxiedMain string `yaml:"-" json:"-"` // used by gomod.proxy
|
||||
UnproxiedDir string `yaml:"-" json:"-"` // used by gomod.proxy
|
||||
|
@ -207,6 +207,8 @@ builds:
|
||||
# created, you can set this property.
|
||||
# If you do, you are responsible for keeping different builds from
|
||||
# overriding each other.
|
||||
#
|
||||
# Templates: allowed (since v2.3).
|
||||
no_unique_dist_dir: true
|
||||
|
||||
# By default, GoReleaser will check if the main filepath has a main
|
||||
|
Loading…
x
Reference in New Issue
Block a user