You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	feat: add ability to skip prereleases for scoop pipeline (#1332)
This commit is contained in:
		| @@ -6,6 +6,7 @@ import ( | |||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | 	"strings" | ||||||
|  |  | ||||||
| 	"github.com/goreleaser/goreleaser/internal/artifact" | 	"github.com/goreleaser/goreleaser/internal/artifact" | ||||||
| 	"github.com/goreleaser/goreleaser/internal/client" | 	"github.com/goreleaser/goreleaser/internal/client" | ||||||
| @@ -85,6 +86,14 @@ func doRun(ctx *context.Context, client client.Client) error { | |||||||
|  |  | ||||||
| 	if ctx.SkipPublish { | 	if ctx.SkipPublish { | ||||||
| 		return pipe.ErrSkipPublishEnabled | 		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 { | 	if ctx.Config.Release.Draft { | ||||||
| 		return pipe.Skip("release is marked as 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"), | 			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", | 			"release is disabled", | ||||||
| 			args{ | 			args{ | ||||||
|   | |||||||
| @@ -81,6 +81,7 @@ type Scoop struct { | |||||||
| 	License      string       `yaml:",omitempty"` | 	License      string       `yaml:",omitempty"` | ||||||
| 	URLTemplate  string       `yaml:"url_template,omitempty"` | 	URLTemplate  string       `yaml:"url_template,omitempty"` | ||||||
| 	Persist      []string     `yaml:"persist,omitempty"` | 	Persist      []string     `yaml:"persist,omitempty"` | ||||||
|  | 	SkipUpload   string       `yaml:"skip_upload,omitempty"` | ||||||
| } | } | ||||||
|  |  | ||||||
| // CommitAuthor is the author of a Git commit | // CommitAuthor is the author of a Git commit | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user