mirror of
https://github.com/goreleaser/goreleaser.git
synced 2026-06-19 23:24:39 +02:00
feat: add ability to skip prereleases for scoop pipeline (#1332)
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||
"github.com/goreleaser/goreleaser/internal/client"
|
||||
@@ -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")
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user