diff --git a/internal/pipe/scoop/scoop.go b/internal/pipe/scoop/scoop.go index d2a2f197f..7d849a84a 100644 --- a/internal/pipe/scoop/scoop.go +++ b/internal/pipe/scoop/scoop.go @@ -149,6 +149,18 @@ func doRun(ctx *context.Context, scoop config.Scoop, cl client.ReleaserURLTempla } scoop.Name = name + description, err := tmpl.New(ctx).Apply(scoop.Description) + if err != nil { + return err + } + scoop.Description = description + + homepage, err := tmpl.New(ctx).Apply(scoop.Homepage) + if err != nil { + return err + } + scoop.Homepage = homepage + ref, err := client.TemplateRef(tmpl.New(ctx).Apply, scoop.Bucket) if err != nil { return err diff --git a/internal/pipe/scoop/scoop_test.go b/internal/pipe/scoop/scoop_test.go index c89ed8cf9..2f77f7859 100644 --- a/internal/pipe/scoop/scoop_test.go +++ b/internal/pipe/scoop/scoop_test.go @@ -566,6 +566,114 @@ func Test_doRun(t *testing.T) { shouldNotErr, noAssertions, }, + { + "invalid name tmpl", + args{ + testctx.NewWithCfg( + config.Project{ + ProjectName: "run-pipe", + Scoop: config.Scoop{ + Bucket: config.RepoRef{ + Owner: "test", + Name: "test", + }, + Name: "{{.Nope}}", + }, + }, + testctx.GitHubTokenType, + testctx.WithCurrentTag("v1.0.1"), + testctx.WithVersion("1.0.1"), + ), + client.NewMock(), + }, + []artifact.Artifact{ + {Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, + }, + testlib.RequireTemplateError, + shouldNotErr, + noAssertions, + }, + { + "invalid description tmpl", + args{ + testctx.NewWithCfg( + config.Project{ + ProjectName: "run-pipe", + Scoop: config.Scoop{ + Bucket: config.RepoRef{ + Owner: "test", + Name: "test", + }, + Description: "{{.Nope}}", + }, + }, + testctx.GitHubTokenType, + testctx.WithCurrentTag("v1.0.1"), + testctx.WithVersion("1.0.1"), + ), + client.NewMock(), + }, + []artifact.Artifact{ + {Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, + }, + testlib.RequireTemplateError, + shouldNotErr, + noAssertions, + }, + { + "invalid homepage tmpl", + args{ + testctx.NewWithCfg( + config.Project{ + ProjectName: "run-pipe", + Scoop: config.Scoop{ + Bucket: config.RepoRef{ + Owner: "test", + Name: "test", + }, + Homepage: "{{.Nope}}", + }, + }, + testctx.GitHubTokenType, + testctx.WithCurrentTag("v1.0.1"), + testctx.WithVersion("1.0.1"), + ), + client.NewMock(), + }, + []artifact.Artifact{ + {Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, + }, + testlib.RequireTemplateError, + shouldNotErr, + noAssertions, + }, + { + "invalid skip upload tmpl", + args{ + testctx.NewWithCfg( + config.Project{ + ProjectName: "run-pipe", + Scoop: config.Scoop{ + Bucket: config.RepoRef{ + Owner: "test", + Name: "test", + }, + SkipUpload: "{{.Nope}}", + }, + }, + testctx.GitHubTokenType, + testctx.WithCurrentTag("v1.0.1"), + testctx.WithVersion("1.0.1"), + ), + client.NewMock(), + }, + []artifact.Artifact{ + {Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, + }, + testlib.RequireTemplateError, + shouldNotErr, + noAssertions, + }, { "invalid ref tmpl", args{ @@ -655,9 +763,9 @@ func TestRunPipePullRequest(t *testing.T) { Dist: folder, ProjectName: "foo", Scoops: []config.Scoop{{ - Name: "foo", - Homepage: "https://goreleaser.com", - Description: "Fake desc", + Name: "{{.Env.FOO}}", + Homepage: "https://{{.Env.FOO}}.com", + Description: "Fake desc for {{.ProjectName}}", Bucket: config.RepoRef{ Owner: "foo", Name: "bar", @@ -670,6 +778,7 @@ func TestRunPipePullRequest(t *testing.T) { }, testctx.WithVersion("1.2.1"), testctx.WithCurrentTag("v1.2.1"), + testctx.WithEnv(map[string]string{"FOO": "foobar"}), ) path := filepath.Join(folder, "dist/foo_windows_amd64/foo.exe") ctx.Artifacts.Add(&artifact.Artifact{ diff --git a/internal/pipe/scoop/testdata/TestRunPipePullRequest.json.golden b/internal/pipe/scoop/testdata/TestRunPipePullRequest.json.golden index fd5fdfc46..f2a98b9eb 100644 --- a/internal/pipe/scoop/testdata/TestRunPipePullRequest.json.golden +++ b/internal/pipe/scoop/testdata/TestRunPipePullRequest.json.golden @@ -7,6 +7,6 @@ "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" } }, - "homepage": "https://goreleaser.com", - "description": "Fake desc" + "homepage": "https://foobar.com", + "description": "Fake desc for foo" } \ No newline at end of file diff --git a/www/docs/customization/scoop.md b/www/docs/customization/scoop.md index c002adc06..14c1d1cc1 100644 --- a/www/docs/customization/scoop.md +++ b/www/docs/customization/scoop.md @@ -124,9 +124,13 @@ scoops: commit_msg_template: "Scoop update for {{ .ProjectName }} version {{ .Tag }}" # Your app's homepage. + # + # Templates: allowed (since v1.19) homepage: "https://example.com/" # Your app's description. + # + # Templates: allowed (since v1.19) description: "Software to create fast and easy drum rolls." # Your app's license