1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-04-13 11:50:34 +02:00

feat: ability to skip Homebrew Tap update for preleases (#943)

- Updates Homebrew config to make "SkipUpload" a string so that it can
  contain more than true or false values. New available options are
  "true", "false" and "auto".
- Adds a new check in Homebrew publish to see if it should skip due to a
  prerelease and "SkipUpload" set to auto.
- Adds a new test to make sure that tap publishing is skipped when set
  to "auto" and a prerelease semver is provided.
- Updates documents to add information about the new "auto" option for
  "SkipUpload".
This commit is contained in:
Andrew Hamilton 2019-01-30 03:28:05 -08:00 committed by Carlos Alexandro Becker
parent d183891332
commit f7bfac8e6f
4 changed files with 23 additions and 6 deletions

View File

@ -122,7 +122,7 @@ func doRun(ctx *context.Context, client client.Client) error {
return err
}
if ctx.Config.Brew.SkipUpload {
if strings.TrimSpace(ctx.Config.Brew.SkipUpload) == "true" {
return pipe.Skip("brew.skip_upload is set")
}
if ctx.SkipPublish {
@ -131,6 +131,9 @@ func doRun(ctx *context.Context, client client.Client) error {
if ctx.Config.Release.Draft {
return pipe.Skip("release is marked as draft")
}
if strings.TrimSpace(ctx.Config.Brew.SkipUpload) == "auto" && ctx.Semver.Prerelease != "" {
return pipe.Skip("prerelease detected with 'auto' upload, skipping homebrew publish")
}
var gpath = ghFormulaPath(ctx.Config.Brew.Folder, filename)
log.WithField("formula", gpath).

View File

@ -313,22 +313,34 @@ func TestRunPipeNoUpload(t *testing.T) {
}
t.Run("skip upload", func(tt *testing.T) {
ctx.Config.Release.Draft = false
ctx.Config.Brew.SkipUpload = true
ctx.Config.Brew.SkipUpload = "true"
ctx.SkipPublish = false
assertNoPublish(tt)
})
t.Run("skip publish", func(tt *testing.T) {
ctx.Config.Release.Draft = false
ctx.Config.Brew.SkipUpload = false
ctx.Config.Brew.SkipUpload = "false"
ctx.SkipPublish = true
assertNoPublish(tt)
})
t.Run("draft release", func(tt *testing.T) {
ctx.Config.Release.Draft = true
ctx.Config.Brew.SkipUpload = false
ctx.Config.Brew.SkipUpload = "false"
ctx.SkipPublish = false
assertNoPublish(tt)
})
t.Run("skip prerelease publish", func(tt *testing.T) {
ctx.Config.Release.Draft = false
ctx.Config.Brew.SkipUpload = "auto"
ctx.SkipPublish = false
ctx.Semver = context.Semver{
Major: 1,
Minor: 0,
Patch: 0,
Prerelease: "rc1",
}
assertNoPublish(tt)
})
}
func TestRunPipeFormatBinary(t *testing.T) {

View File

@ -48,7 +48,7 @@ type Homebrew struct {
Conflicts []string `yaml:",omitempty"`
Description string `yaml:",omitempty"`
Homepage string `yaml:",omitempty"`
SkipUpload bool `yaml:"skip_upload,omitempty"`
SkipUpload string `yaml:"skip_upload,omitempty"`
DownloadStrategy string `yaml:"download_strategy,omitempty"`
SourceTarball string `yaml:"-"`
URLTemplate string `yaml:"url_template,omitempty"`

View File

@ -37,7 +37,7 @@ brew:
# Allows you to add a custom require_relative at the top of the formula template
# Default is empty
custom_require: custom_download_strategy 
custom_require: custom_download_strategy
# Git author used to commit to the repository.
# Defaults are shown.
@ -64,6 +64,8 @@ brew:
# Setting this will prevent goreleaser to actually try to commit the updated
# formula - instead, the formula file will be stored on the dist folder only,
# leaving the responsibility of publishing it to the user.
# If set to auto, the release will not be uploaded to the homebrew tap
# in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
# Default is false.
skip_upload: true