Repository: goreleaser/goreleaser
Pull request #1282 (2019-12-27 20:40:54)

feat: remove singular archive config
removed singular `archive` config in favor of its plural form, `archives`.

codecov-io: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1282?src=pr&el=h1) Report
> Merging [#1282](https://codecov.io/gh/goreleaser/goreleaser/pull/1282?src=pr&el=desc) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/468401bc54d3a31aebcc1526ba803760a80b51c3?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/1282/graphs/tree.svg?width=650&token=3bJvv6b7hN&height=150&src=pr)](https://codecov.io/gh/goreleaser/goreleaser/pull/1282?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1282      +/-   ##
==========================================
- Coverage   83.83%   83.82%   -0.01%     
==========================================
  Files          59       59              
  Lines        3360     3358       -2     
==========================================
- Hits         2817     2815       -2     
  Misses        461      461              
  Partials       82       82
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/1282?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/config/config.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1282/diff?src=pr&el=tree#diff-cGtnL2NvbmZpZy9jb25maWcuZ28=) | `100% <ø> (ø)` | :arrow_up: |
| [internal/pipe/archive/archive.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1282/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9hcmNoaXZlL2FyY2hpdmUuZ28=) | `96.2% <100%> (-0.05%)` | :arrow_down: |
| [internal/pipe/scoop/scoop.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1282/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9zY29vcC9zY29vcC5nbw==) | `91.91% <100%> (ø)` | :arrow_up: |
| [internal/http/http.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1282/diff?src=pr&el=tree#diff-aW50ZXJuYWwvaHR0cC9odHRwLmdv) | `90.24% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1282?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1282?src=pr&el=footer). Last update [468401b...9af63e9](https://codecov.io/gh/goreleaser/goreleaser/pull/1282?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/internal/http/http.go b/internal/http/http.go
index 63cad0a0..6540ccb6 100644
--- a/internal/http/http.go
+++ b/internal/http/http.go
@@ -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
diff --git a/internal/pipe/archive/archive.go b/internal/pipe/archive/archive.go
index 5f82721b..987c7024 100644
--- a/internal/pipe/archive/archive.go
+++ b/internal/pipe/archive/archive.go
@@ -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]
diff --git a/internal/pipe/scoop/scoop.go b/internal/pipe/scoop/scoop.go
index 494b15e0..a512627e 100644
--- a/internal/pipe/scoop/scoop.go
+++ b/internal/pipe/scoop/scoop.go
@@ -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")
 	}
 
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 79fd4116..feb70008 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -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"`
diff --git a/www/content/deprecations.md b/www/content/deprecations.md
index d9442d4a..d44f8c9b 100644
--- a/www/content/deprecations.md
+++ b/www/content/deprecations.md
@@ -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


Test patch:
diff --git a/internal/http/http_test.go b/internal/http/http_test.go
index e99e6653..417db688 100644
--- a/internal/http/http_test.go
+++ b/internal/http/http_test.go
@@ -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"
diff --git a/internal/pipe/artifactory/artifactory_test.go b/internal/pipe/artifactory/artifactory_test.go
index e1b50108..6694370d 100644
--- a/internal/pipe/artifactory/artifactory_test.go
+++ b/internal/pipe/artifactory/artifactory_test.go
@@ -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",
diff --git a/internal/pipe/defaults/defaults_test.go b/internal/pipe/defaults/defaults_test.go
index 269d713d..a3d96fc3 100644
--- a/internal/pipe/defaults/defaults_test.go
+++ b/internal/pipe/defaults/defaults_test.go
@@ -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)
diff --git a/internal/pipe/scoop/scoop_test.go b/internal/pipe/scoop/scoop_test.go
index ecba4d04..f6b31f6f 100644
--- a/internal/pipe/scoop/scoop_test.go
+++ b/internal/pipe/scoop/scoop_test.go
@@ -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{
diff --git a/internal/pipe/upload/upload_test.go b/internal/pipe/upload/upload_test.go
index b7ce8708..1092e32c 100644
--- a/internal/pipe/upload/upload_test.go
+++ b/internal/pipe/upload/upload_test.go
@@ -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",