mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-29 01:44:39 +02:00
feat: allow to template builds.gobinary (#4454)
closes #4453 TODO: tests
This commit is contained in:
parent
7e481967b3
commit
22fa9947c8
@ -195,12 +195,13 @@ func buildOptionsForTarget(ctx *context.Context, build config.Build, target stri
|
||||
Goamd64: goamd64,
|
||||
}
|
||||
|
||||
binary, err := tmpl.New(ctx).WithBuildOptions(buildOpts).Apply(build.Binary)
|
||||
if err != nil {
|
||||
if err := tmpl.New(ctx).WithBuildOptions(buildOpts).ApplyAll(
|
||||
&build.Binary,
|
||||
&build.GoBinary,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
build.Binary = binary
|
||||
name := build.Binary + ext
|
||||
dir := fmt.Sprintf("%s_%s", build.ID, target)
|
||||
if build.NoUniqueDistDir {
|
||||
|
@ -570,6 +570,24 @@ func TestPipeOnBuild_hooksRunPerTarget(t *testing.T) {
|
||||
require.FileExists(t, filepath.Join(tmpDir, "post-hook-windows_amd64"))
|
||||
}
|
||||
|
||||
func TestPipeOnBuild_invalidGoBinary(t *testing.T) {
|
||||
build := config.Build{
|
||||
Builder: "fake",
|
||||
GoBinary: "testing.v{{.XYZ}}",
|
||||
Targets: []string{
|
||||
"linux_amd64",
|
||||
},
|
||||
}
|
||||
ctx := testctx.NewWithCfg(config.Project{
|
||||
Builds: []config.Build{
|
||||
build,
|
||||
},
|
||||
})
|
||||
g := semerrgroup.New(ctx.Parallelism)
|
||||
runPipeOnBuild(ctx, g, build)
|
||||
testlib.RequireTemplateError(t, g.Wait())
|
||||
}
|
||||
|
||||
func TestPipeOnBuild_invalidBinaryTpl(t *testing.T) {
|
||||
build := config.Build{
|
||||
Builder: "fake",
|
||||
|
@ -169,6 +169,7 @@ builds:
|
||||
# It is safe to ignore this option in most cases.
|
||||
#
|
||||
# Default is "go"
|
||||
# Templates: allowed (since v1.23).
|
||||
gobinary: "go1.13.4"
|
||||
|
||||
# Sets the command to run to build.
|
||||
|
Loading…
Reference in New Issue
Block a user