You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	feat: remove singular archive config (#1282)
* feat: remove singular archive config Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							468401bc54
						
					
				
				
					commit
					8defb77b0e
				
			| @@ -372,9 +372,9 @@ func resolveTargetTemplate(ctx *context.Context, upload *config.Upload, artifact | ||||
|  | ||||
| 	if upload.Mode == ModeBinary { | ||||
| 		// TODO: multiple archives here | ||||
| 		data.Os = replace(ctx.Config.Archive.Replacements, artifact.Goos) | ||||
| 		data.Arch = replace(ctx.Config.Archive.Replacements, artifact.Goarch) | ||||
| 		data.Arm = replace(ctx.Config.Archive.Replacements, artifact.Goarm) | ||||
| 		data.Os = replace(ctx.Config.Archives[0].Replacements, artifact.Goos) | ||||
| 		data.Arch = replace(ctx.Config.Archives[0].Replacements, artifact.Goarch) | ||||
| 		data.Arm = replace(ctx.Config.Archives[0].Replacements, artifact.Goarm) | ||||
| 	} | ||||
|  | ||||
| 	var out bytes.Buffer | ||||
|   | ||||
| @@ -205,7 +205,12 @@ func TestUpload(t *testing.T) { | ||||
| 		} | ||||
| 		return errors.Errorf("unexpected http status code: %v", r.StatusCode) | ||||
| 	} | ||||
| 	ctx := context.New(config.Project{ProjectName: "blah"}) | ||||
| 	ctx := context.New(config.Project{ | ||||
| 		ProjectName: "blah", | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env["TEST_A_SECRET"] = "x" | ||||
| 	ctx.Env["TEST_A_USERNAME"] = "u2" | ||||
| 	ctx.Version = "2.1.0" | ||||
|   | ||||
| @@ -7,14 +7,14 @@ import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"reflect" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/apex/log" | ||||
| 	"github.com/campoy/unique" | ||||
| 	"github.com/mattn/go-zglob" | ||||
|  | ||||
| 	"github.com/goreleaser/goreleaser/internal/artifact" | ||||
| 	"github.com/goreleaser/goreleaser/internal/deprecate" | ||||
| 	"github.com/goreleaser/goreleaser/internal/ids" | ||||
| 	"github.com/goreleaser/goreleaser/internal/semerrgroup" | ||||
| 	"github.com/goreleaser/goreleaser/internal/tmpl" | ||||
| @@ -22,7 +22,6 @@ import ( | ||||
| 	archivelib "github.com/goreleaser/goreleaser/pkg/archive" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/config" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/context" | ||||
| 	zglob "github.com/mattn/go-zglob" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -44,10 +43,7 @@ func (Pipe) String() string { | ||||
| func (Pipe) Default(ctx *context.Context) error { | ||||
| 	var ids = ids.New("archives") | ||||
| 	if len(ctx.Config.Archives) == 0 { | ||||
| 		ctx.Config.Archives = append(ctx.Config.Archives, ctx.Config.Archive) | ||||
| 		if !reflect.DeepEqual(ctx.Config.Archive, config.Archive{}) { | ||||
| 			deprecate.Notice("archive") | ||||
| 		} | ||||
| 		ctx.Config.Archives = append(ctx.Config.Archives, config.Archive{}) | ||||
| 	} | ||||
| 	for i := range ctx.Config.Archives { | ||||
| 		var archive = &ctx.Config.Archives[i] | ||||
|   | ||||
| @@ -188,6 +188,9 @@ func TestRunPipe_ModeBinary(t *testing.T) { | ||||
| 				Username: "productionuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION-US_SECRET": "deployuser-secret", | ||||
| @@ -229,6 +232,9 @@ func TestRunPipe_ModeArchive(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -361,6 +367,9 @@ func TestRunPipe_TargetTemplateError(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -418,6 +427,9 @@ func TestRunPipe_BadCredentials(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -476,6 +488,9 @@ func TestRunPipe_UnparsableErrorResponse(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -531,6 +546,9 @@ func TestRunPipe_UnparsableResponse(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -559,6 +577,9 @@ func TestRunPipe_FileNotFound(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -597,6 +618,9 @@ func TestRunPipe_UnparsableTarget(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -623,6 +647,9 @@ func TestRunPipe_SkipWhenPublishFalse(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -654,6 +681,9 @@ func TestRunPipe_DirUpload(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret", | ||||
|   | ||||
| @@ -63,9 +63,11 @@ func TestFillPartial(t *testing.T) { | ||||
| 					Name:  "test", | ||||
| 				}, | ||||
| 			}, | ||||
| 			Archive: config.Archive{ | ||||
| 				Files: []string{ | ||||
| 					"glob/*", | ||||
| 			Archives: []config.Archive{ | ||||
| 				{ | ||||
| 					Files: []string{ | ||||
| 						"glob/*", | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			Builds: []config.Build{ | ||||
| @@ -90,7 +92,7 @@ func TestFillPartial(t *testing.T) { | ||||
| 		}, | ||||
| 	} | ||||
| 	assert.NoError(t, Pipe{}.Run(ctx)) | ||||
| 	assert.Len(t, ctx.Config.Archive.Files, 1) | ||||
| 	assert.Len(t, ctx.Config.Archives[0].Files, 1) | ||||
| 	assert.Equal(t, `bin.install "testreleaser"`, ctx.Config.Brews[0].Install) | ||||
| 	assert.NotEmpty(t, ctx.Config.Dockers[0].Binaries) | ||||
| 	assert.NotEmpty(t, ctx.Config.Dockers[0].Goos) | ||||
|   | ||||
| @@ -61,7 +61,8 @@ func doRun(ctx *context.Context, client client.Client) error { | ||||
| 	// if ctx.Config.Release.Disable { | ||||
| 	// } | ||||
|  | ||||
| 	if ctx.Config.Archive.Format == "binary" { | ||||
| 	// TODO: multiple archives | ||||
| 	if ctx.Config.Archives[0].Format == "binary" { | ||||
| 		return pipe.Skip("archive format is binary") | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -101,8 +101,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							GitHub: config.Repo{ | ||||
| @@ -145,8 +145,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							GitHub: config.Repo{ | ||||
| @@ -188,8 +188,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							GitLab: config.Repo{ | ||||
| @@ -248,8 +248,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							GitHub: config.Repo{ | ||||
| @@ -306,8 +306,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							GitHub: config.Repo{ | ||||
| @@ -349,8 +349,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							GitHub: config.Repo{ | ||||
| @@ -392,8 +392,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							GitHub: config.Repo{ | ||||
| @@ -427,8 +427,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							GitHub: config.Repo{ | ||||
| @@ -471,8 +471,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							Draft: true, | ||||
| @@ -511,8 +511,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "tar.gz", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "tar.gz"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							Disable: true, | ||||
| @@ -551,8 +551,8 @@ func Test_doRun(t *testing.T) { | ||||
| 						}, | ||||
| 						Dist:        ".", | ||||
| 						ProjectName: "run-pipe", | ||||
| 						Archive: config.Archive{ | ||||
| 							Format: "binary", | ||||
| 						Archives: []config.Archive{ | ||||
| 							{Format: "binary"}, | ||||
| 						}, | ||||
| 						Release: config.Release{ | ||||
| 							Draft: true, | ||||
| @@ -613,8 +613,8 @@ func Test_buildManifest(t *testing.T) { | ||||
| 					}, | ||||
| 					Dist:        ".", | ||||
| 					ProjectName: "run-pipe", | ||||
| 					Archive: config.Archive{ | ||||
| 						Format: "tar.gz", | ||||
| 					Archives: []config.Archive{ | ||||
| 						{Format: "tar.gz"}, | ||||
| 					}, | ||||
| 					Release: config.Release{ | ||||
| 						GitHub: config.Repo{ | ||||
| @@ -652,8 +652,8 @@ func Test_buildManifest(t *testing.T) { | ||||
| 					}, | ||||
| 					Dist:        ".", | ||||
| 					ProjectName: "run-pipe", | ||||
| 					Archive: config.Archive{ | ||||
| 						Format: "tar.gz", | ||||
| 					Archives: []config.Archive{ | ||||
| 						{Format: "tar.gz"}, | ||||
| 					}, | ||||
| 					Release: config.Release{ | ||||
| 						GitHub: config.Repo{ | ||||
| @@ -692,8 +692,8 @@ func Test_buildManifest(t *testing.T) { | ||||
| 					}, | ||||
| 					Dist:        ".", | ||||
| 					ProjectName: "run-pipe", | ||||
| 					Archive: config.Archive{ | ||||
| 						Format: "tar.gz", | ||||
| 					Archives: []config.Archive{ | ||||
| 						{Format: "tar.gz"}, | ||||
| 					}, | ||||
| 					Release: config.Release{ | ||||
| 						GitHub: config.Repo{ | ||||
|   | ||||
| @@ -123,6 +123,9 @@ func TestRunPipe_ModeBinary(t *testing.T) { | ||||
| 				Username: "productionuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"UPLOAD_PRODUCTION-US_SECRET": "deployuser-secret", | ||||
| @@ -164,6 +167,9 @@ func TestRunPipe_ModeArchive(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"UPLOAD_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -261,6 +267,9 @@ func TestRunPipe_TargetTemplateError(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"UPLOAD_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -313,6 +322,9 @@ func TestRunPipe_BadCredentials(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"UPLOAD_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -343,6 +355,9 @@ func TestRunPipe_FileNotFound(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"UPLOAD_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -381,6 +396,9 @@ func TestRunPipe_UnparsableTarget(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"UPLOAD_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -406,6 +424,9 @@ func TestRunPipe_SkipWhenPublishFalse(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"UPLOAD_PRODUCTION_SECRET": "deployuser-secret", | ||||
| @@ -437,6 +458,9 @@ func TestRunPipe_DirUpload(t *testing.T) { | ||||
| 				Username: "deployuser", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Archives: []config.Archive{ | ||||
| 			{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	ctx.Env = map[string]string{ | ||||
| 		"UPLOAD_PRODUCTION_SECRET": "deployuser-secret", | ||||
|   | ||||
| @@ -358,7 +358,6 @@ type Project struct { | ||||
| 	Brews         []Homebrew  `yaml:",omitempty"` | ||||
| 	Scoop         Scoop       `yaml:",omitempty"` | ||||
| 	Builds        []Build     `yaml:",omitempty"` | ||||
| 	Archive       Archive     `yaml:",omitempty"` // TODO: remove this | ||||
| 	Archives      []Archive   `yaml:",omitempty"` | ||||
| 	NFPMs         []NFPM      `yaml:"nfpms,omitempty"` | ||||
| 	Snapcrafts    []Snapcraft `yaml:",omitempty"` | ||||
|   | ||||
| @@ -175,9 +175,13 @@ blobs: | ||||
|   # etc | ||||
| ``` | ||||
|  | ||||
| ## Expired deprecation notices | ||||
|  | ||||
| The following options were deprecated for ~6 months and are now fully removed. | ||||
|  | ||||
| ### archive | ||||
|  | ||||
| > since 2019-04-16 | ||||
| > since 2019-04-16, removed 2019-12-27 | ||||
|  | ||||
| We now allow multiple archives, so the `archive` statement will be removed. | ||||
|  | ||||
| @@ -196,11 +200,6 @@ archives: | ||||
|     format: zip | ||||
| ``` | ||||
|  | ||||
| ## Expired deprecation notices | ||||
|  | ||||
| The following options were deprecated for ~6 months and are now fully removed. | ||||
|  | ||||
|  | ||||
| ### snapcraft | ||||
|  | ||||
| > since 2019-05-27, removed 2019-12-27 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user