Skip to content

Commit

Permalink
feat: add ability to skip prereleases for scoop pipeline (#1332)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Smith committed Feb 6, 2020
1 parent ca3a63a commit 16fe0ea
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/pipe/scoop/scoop.go
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"

"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/client"
Expand Down Expand Up @@ -85,6 +86,14 @@ func doRun(ctx *context.Context, client client.Client) error {

if ctx.SkipPublish {
return pipe.ErrSkipPublishEnabled

}
if strings.TrimSpace(ctx.Config.Scoop.SkipUpload) == "true" {
return pipe.Skip("scoop.skip_upload is true")
} else if strings.TrimSpace(ctx.Config.Scoop.SkipUpload) == "auto" {
if ctx.Semver.Prerelease != "" {
return pipe.Skip("release is prerelease")
}
}
if ctx.Config.Release.Draft {
return pipe.Skip("release is marked as draft")
Expand Down
94 changes: 94 additions & 0 deletions internal/pipe/scoop/scoop_test.go
Expand Up @@ -495,6 +495,100 @@ func Test_doRun(t *testing.T) {
},
shouldErr("release is marked as draft"),
},
{
"is prerelease and skip upload set to auto",
args{
&context.Context{
TokenType: context.TokenTypeGitHub,
Git: context.GitInfo{
CurrentTag: "v1.0.1-pre.1",
},
Semver: context.Semver{
Major: 1,
Minor: 0,
Patch: 1,
Prerelease: "-pre.1",
},
Version: "1.0.1-pre.1",
Artifacts: artifact.New(),
Config: config.Project{
Builds: []config.Build{
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
},
Dist: ".",
ProjectName: "run-pipe",
Archives: []config.Archive{
{Format: "tar.gz"},
},
Release: config.Release{
GitHub: config.Repo{
Owner: "test",
Name: "test",
},
},
Scoop: config.Scoop{
SkipUpload: "auto",
Bucket: config.Repo{
Owner: "test",
Name: "test",
},
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
},
},
},
&DummyClient{},
},
[]*artifact.Artifact{
{Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
{Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
},
shouldErr("release is prerelease"),
},
{
"skip upload set to true",
args{
&context.Context{
TokenType: context.TokenTypeGitHub,
Git: context.GitInfo{
CurrentTag: "v1.0.1",
},
Version: "1.0.1",
Artifacts: artifact.New(),
Config: config.Project{
Builds: []config.Build{
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
},
Dist: ".",
ProjectName: "run-pipe",
Archives: []config.Archive{
{Format: "tar.gz"},
},
Release: config.Release{
GitHub: config.Repo{
Owner: "test",
Name: "test",
},
},
Scoop: config.Scoop{
SkipUpload: "true",
Bucket: config.Repo{
Owner: "test",
Name: "test",
},
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
},
},
},
&DummyClient{},
},
[]*artifact.Artifact{
{Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
{Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
},
shouldErr("scoop.skip_upload is true"),
},
{
"release is disabled",
args{
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Expand Up @@ -81,6 +81,7 @@ type Scoop struct {
License string `yaml:",omitempty"`
URLTemplate string `yaml:"url_template,omitempty"`
Persist []string `yaml:"persist,omitempty"`
SkipUpload string `yaml:"skip_upload,omitempty"`
}

// CommitAuthor is the author of a Git commit
Expand Down

0 comments on commit 16fe0ea

Please sign in to comment.