1
0
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:
Carlos Alexandro Becker 2023-12-04 23:00:11 -03:00 committed by GitHub
parent 7e481967b3
commit 22fa9947c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View File

@ -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 {

View File

@ -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",

View File

@ -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.