Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to template builds.gobinary #4454

Merged
merged 3 commits into from Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions internal/pipe/build/build.go
Expand Up @@ -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 {
Expand Down
18 changes: 18 additions & 0 deletions internal/pipe/build/build_test.go
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions www/docs/customization/builds.md
Expand Up @@ -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.
Expand Down