mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-04 03:11:55 +02:00
feat: add template support for homebrew skip_upload (#2562)
This commit is contained in:
parent
0aae8d7815
commit
33d857e347
@ -190,6 +190,12 @@ func doRun(ctx *context.Context, brew config.Homebrew, cl client.Client) error {
|
||||
}
|
||||
brew.Tap.Name = tapName
|
||||
|
||||
skipUpload, err := tmpl.New(ctx).Apply(brew.SkipUpload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
brew.SkipUpload = skipUpload
|
||||
|
||||
content, err := buildFormula(ctx, brew, cl, archives)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -237,6 +237,14 @@ func TestFullPipe(t *testing.T) {
|
||||
},
|
||||
expectedRunError: `template: tmpl:1: unexpected "}" in operand`,
|
||||
},
|
||||
"invalid_tap_skip_upload_template": {
|
||||
prepare: func(ctx *context.Context) {
|
||||
ctx.Config.Brews[0].SkipUpload = "{{ .Asdsa }"
|
||||
ctx.Config.Brews[0].Tap.Owner = "test"
|
||||
ctx.Config.Brews[0].Tap.Name = "test"
|
||||
},
|
||||
expectedRunError: `template: tmpl:1: unexpected "}" in operand`,
|
||||
},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
folder := t.TempDir()
|
||||
@ -387,7 +395,8 @@ func TestRunPipeMultipleBrewsWithSkip(t *testing.T) {
|
||||
Version: "1.0.1",
|
||||
Artifacts: artifact.New(),
|
||||
Env: map[string]string{
|
||||
"FOO_BAR": "is_bar",
|
||||
"FOO_BAR": "is_bar",
|
||||
"SKIP_UPLOAD": "true",
|
||||
},
|
||||
Config: config.Project{
|
||||
Dist: folder,
|
||||
@ -425,6 +434,17 @@ func TestRunPipeMultipleBrewsWithSkip(t *testing.T) {
|
||||
},
|
||||
SkipUpload: "true",
|
||||
},
|
||||
{
|
||||
Name: "baz",
|
||||
Tap: config.RepoRef{
|
||||
Owner: "foo",
|
||||
Name: "bar",
|
||||
},
|
||||
IDs: []string{
|
||||
"foo",
|
||||
},
|
||||
SkipUpload: "{{ .Env.SKIP_UPLOAD }}",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -787,6 +807,9 @@ func TestRunPipeNoUpload(t *testing.T) {
|
||||
},
|
||||
},
|
||||
})
|
||||
ctx.Env = map[string]string{
|
||||
"SKIP_UPLOAD": "true",
|
||||
}
|
||||
ctx.TokenType = context.TokenTypeGitHub
|
||||
ctx.Git = context.GitInfo{CurrentTag: "v1.0.1"}
|
||||
path := filepath.Join(folder, "whatever.tar.gz")
|
||||
@ -817,6 +840,11 @@ func TestRunPipeNoUpload(t *testing.T) {
|
||||
ctx.Semver.Prerelease = ""
|
||||
assertNoPublish(t)
|
||||
})
|
||||
t.Run("skip upload true set by template", func(t *testing.T) {
|
||||
ctx.Config.Brews[0].SkipUpload = "{{.Env.SKIP_UPLOAD}}"
|
||||
ctx.Semver.Prerelease = ""
|
||||
assertNoPublish(t)
|
||||
})
|
||||
t.Run("skip upload auto", func(t *testing.T) {
|
||||
ctx.Config.Brews[0].SkipUpload = "auto"
|
||||
ctx.Semver.Prerelease = "beta1"
|
||||
|
Loading…
Reference in New Issue
Block a user