Repository: goreleaser/goreleaser
Pull request #1372 (2020-03-04 03:22:51)

feat: upgrade to go 1.14
<!-- If applied, this commit will... -->

Upgrade builds, docker images, examples and tests from go 1.13 to 1.14.

<!-- Why is this change being made? -->

<!-- # Provide links to any relevant tickets, URLs or other resources -->



Patch:
diff --git a/.travis.yml b/.travis.yml
index ef773c86..a5cab594 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
 dist: bionic
 language: go
-go: '1.13.x'
+go: '1.14.x'
 services:
   - docker
 addons:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c9644a7b..a2107fd8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -10,7 +10,7 @@ conduct](/CODE_OF_CONDUCT.md).
 Prerequisites:
 
 - `make`
-- [Go 1.13+](https://golang.org/doc/install)
+- [Go 1.14+](https://golang.org/doc/install)
 - [snapcraft](https://snapcraft.io/)
 - [Docker](https://www.docker.com/)
 - `gpg` (probably already installed on your system)
diff --git a/Dockerfile b/Dockerfile
index 1836386a..e63e46e2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM golang:1.13-alpine
+FROM golang:1.14-alpine
 
 RUN apk add --no-cache bash \
                        bzr \
diff --git a/Dockerfile.cgo b/Dockerfile.cgo
index 9f7e4db0..e2f4fb77 100644
--- a/Dockerfile.cgo
+++ b/Dockerfile.cgo
@@ -1,4 +1,4 @@
-FROM golang:1.13-alpine
+FROM golang:1.14-alpine
 
 RUN apk add --no-cache bash \
                        build-base \
diff --git a/Makefile b/Makefile
index 6f3851c3..466bed99 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ export GOPROXY = https://proxy.golang.org,direct
 
 # Install all the build and lint dependencies
 setup:
-	curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- v1.23.1
+	curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- v1.23.7
 	curl -sfL https://install.goreleaser.com/github.com/gohugoio/hugo.sh | sh -s -- v0.63.2
 	curl -sfL https://git.io/misspell | sh -s -- v0.3.4
 	go mod tidy
diff --git a/go.mod b/go.mod
index 40c90713..9e9331ce 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/goreleaser/goreleaser
 
-go 1.13
+go 1.14
 
 require (
 	code.gitea.io/sdk/gitea v0.0.0-20200128061546-ea2b5af37297
diff --git a/go.sum b/go.sum
index 31b1e4fe..8f30675b 100644
--- a/go.sum
+++ b/go.sum
@@ -145,10 +145,6 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht
 github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
 github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0=
 github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
-github.com/kamilsk/retry/v4 v4.5.0 h1:TcfpmIdzFEfSWLwHJhA+WPAmo5qT2pl/HqqzFat2M+I=
-github.com/kamilsk/retry/v4 v4.5.0/go.mod h1:pIQtBtycHTXScrJmpu3N2SSBT07s07Uruq2Au1aRLks=
-github.com/kamilsk/retry/v4 v4.7.1 h1:mNg/RQ1X9QlInxBqz63ubBXgh/7D63aePBWZbQQr7pE=
-github.com/kamilsk/retry/v4 v4.7.1/go.mod h1:pIQtBtycHTXScrJmpu3N2SSBT07s07Uruq2Au1aRLks=
 github.com/kamilsk/retry/v4 v4.7.2 h1:8C33aqTQtTSvPf7MpLZ4xSY4JZK2YCvY+hTlsbiHNq8=
 github.com/kamilsk/retry/v4 v4.7.2/go.mod h1:pIQtBtycHTXScrJmpu3N2SSBT07s07Uruq2Au1aRLks=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
@@ -202,8 +198,6 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
-github.com/stretchr/testify v1.5.0 h1:DMOzIV76tmoDNE9pX6RSN0aDtCYeCg5VueieJaAo1uw=
-github.com/stretchr/testify v1.5.0/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
 github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
 github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
 github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
@@ -212,8 +206,6 @@ github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPf
 github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4=
 github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=
 github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
-github.com/xanzy/go-gitlab v0.26.0 h1:eAnJRBUC+GDJSy8OoGCZBqBMpXsGOOT235TFm/F8C0Q=
-github.com/xanzy/go-gitlab v0.26.0/go.mod h1:t4Bmvnxj7k37S4Y17lfLx+nLqkf/oQwT2HagfWKv5Og=
 github.com/xanzy/go-gitlab v0.27.0 h1:zy7xBB8+PID6izH07ZArtkEisJ192dtQajRaeo4+glg=
 github.com/xanzy/go-gitlab v0.27.0/go.mod h1:t4Bmvnxj7k37S4Y17lfLx+nLqkf/oQwT2HagfWKv5Og=
 github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
diff --git a/internal/pipe/archive/archive.go b/internal/pipe/archive/archive.go
index 4848c33d..7cb08236 100644
--- a/internal/pipe/archive/archive.go
+++ b/internal/pipe/archive/archive.go
@@ -13,6 +13,7 @@ import (
 	"github.com/apex/log"
 	"github.com/campoy/unique"
 	"github.com/mattn/go-zglob"
+	"github.com/pkg/errors"
 
 	"github.com/goreleaser/goreleaser/internal/artifact"
 	"github.com/goreleaser/goreleaser/internal/ids"
@@ -131,8 +132,9 @@ func create(ctx *context.Context, archive config.Archive, binaries []*artifact.A
 	var log = log.WithField("archive", archivePath)
 	log.Info("creating")
 
-	wrap, err := tmpl.New(ctx).
-		WithArtifact(binaries[0], archive.Replacements).
+	template := tmpl.New(ctx).
+		WithArtifact(binaries[0], archive.Replacements)
+	wrap, err := template.
 		Apply(wrapFolder(archive))
 	if err != nil {
 		return err
@@ -141,7 +143,7 @@ func create(ctx *context.Context, archive config.Archive, binaries []*artifact.A
 	var a = NewEnhancedArchive(archivelib.New(archiveFile), wrap)
 	defer a.Close() // nolint: errcheck
 
-	files, err := findFiles(archive)
+	files, err := findFiles(template, archive)
 	if err != nil {
 		return fmt.Errorf("failed to find files to archive: %s", err.Error())
 	}
@@ -210,11 +212,15 @@ func skip(ctx *context.Context, archive config.Archive, binaries []*artifact.Art
 	return nil
 }
 
-func findFiles(archive config.Archive) (result []string, err error) {
+func findFiles(template *tmpl.Template, archive config.Archive) (result []string, err error) {
 	for _, glob := range archive.Files {
-		files, err := zglob.Glob(glob)
+		replaced, err := template.Apply(glob)
+		if err != nil {
+			return result, errors.Wrapf(err, "failed to apply template %s", glob)
+		}
+		files, err := zglob.Glob(replaced)
 		if err != nil {
-			return result, fmt.Errorf("globbing failed for pattern %s: %s", glob, err.Error())
+			return result, errors.Wrapf(err, "globbing failed for pattern %s", glob)
 		}
 		result = append(result, files...)
 	}
diff --git a/internal/pipe/snapcraft/snapcraft.go b/internal/pipe/snapcraft/snapcraft.go
index 2c3d197a..41090ac7 100644
--- a/internal/pipe/snapcraft/snapcraft.go
+++ b/internal/pipe/snapcraft/snapcraft.go
@@ -141,6 +141,9 @@ func isValidArch(arch string) bool {
 
 // Publish packages
 func (Pipe) Publish(ctx *context.Context) error {
+	if ctx.SkipPublish {
+		return pipe.ErrSkipPublishEnabled
+	}
 	snaps := ctx.Artifacts.Filter(artifact.ByType(artifact.PublishableSnapcraft)).List()
 	var g = semerrgroup.New(ctx.Parallelism)
 	for _, snap := range snaps {
diff --git a/www/content/actions.md b/www/content/actions.md
index de70b338..0ae80de6 100644
--- a/www/content/actions.md
+++ b/www/content/actions.md
@@ -31,7 +31,7 @@ jobs:
         name: Set up Go
         uses: actions/setup-go@v1
         with:
-          go-version: 1.13.x
+          go-version: 1.14.x
       -
         name: Run GoReleaser
         uses: goreleaser/goreleaser-action@v1
diff --git a/www/content/archive.md b/www/content/archive.md
index 416357a9..772c55a2 100644
--- a/www/content/archive.md
+++ b/www/content/archive.md
@@ -62,12 +62,12 @@ archives:
       - goos: windows
         format: zip
 
-    # Additional files/globs you want to add to the archive.
+    # Additional files/template/globs you want to add to the archive.
     # Defaults are any files matching `LICENCE*`, `LICENSE*`,
     # `README*` and `CHANGELOG*` (case-insensitive).
     files:
       - LICENSE.txt
-      - README.md
+      - README_{{.Os}}.md
       - CHANGELOG.md
       - docs/*
       - design/*.png
diff --git a/www/content/ci.md b/www/content/ci.md
index 4e93a873..1e63408e 100644
--- a/www/content/ci.md
+++ b/www/content/ci.md
@@ -73,7 +73,7 @@ workflows:
 jobs:
   release:
     docker:
-      - image: circleci/golang:1.13
+      - image: circleci/golang:1.14
     steps:
       - checkout
       - run: curl -sL https://git.io/goreleaser | bash
@@ -404,7 +404,7 @@ steps:
   BuildMyApp:
     title: Compiling go code
     stage: build
-    image: 'golang:1.13'
+    image: 'golang:1.14'
     commands:
       - go build
   ReleaseMyApp:


Test patch:
diff --git a/internal/client/github_test.go b/internal/client/github_test.go
index 9c967f2d..47503831 100644
--- a/internal/client/github_test.go
+++ b/internal/client/github_test.go
@@ -29,7 +29,7 @@ func TestNewGitHubClient(t *testing.T) {
 			},
 		}))
 
-		require.EqualError(t, err, "parse ://github.mycompany.com/api: missing protocol scheme")
+		require.EqualError(t, err, `parse "://github.mycompany.com/api": missing protocol scheme`)
 	})
 
 	t.Run("bad upload url", func(t *testing.T) {
@@ -40,7 +40,7 @@ func TestNewGitHubClient(t *testing.T) {
 			},
 		}))
 
-		require.EqualError(t, err, "parse not a url:4994: first path segment in URL cannot contain colon")
+		require.EqualError(t, err, `parse "not a url:4994": first path segment in URL cannot contain colon`)
 	})
 }
 
diff --git a/internal/pipe/archive/archive_test.go b/internal/pipe/archive/archive_test.go
index 162a0cc1..c6906d1a 100644
--- a/internal/pipe/archive/archive_test.go
+++ b/internal/pipe/archive/archive_test.go
@@ -4,6 +4,7 @@ import (
 	"archive/tar"
 	"archive/zip"
 	"compress/gzip"
+	"fmt"
 	"io"
 	"io/ioutil"
 	"os"
@@ -39,10 +40,12 @@ func TestRunPipe(t *testing.T) {
 				createFakeBinary(t, dist, arch, "mybin")
 			}
 			createFakeBinary(t, dist, "windowsamd64", "mybin.exe")
-			_, err := os.Create(filepath.Join(folder, "README.md"))
-			require.NoError(t, err)
+			for _, tt := range []string{"darwin", "linux", "windows"} {
+				_, err := os.Create(filepath.Join(folder, fmt.Sprintf("README.%s.md", tt)))
+				require.NoError(t, err)
+			}
 			require.NoError(t, os.MkdirAll(filepath.Join(folder, "foo", "bar", "foobar"), 0755))
-			_, err = os.Create(filepath.Join(filepath.Join(folder, "foo", "bar", "foobar", "blah.txt")))
+			_, err := os.Create(filepath.Join(filepath.Join(folder, "foo", "bar", "foobar", "blah.txt")))
 			require.NoError(t, err)
 			var ctx = context.New(
 				config.Project{
@@ -54,7 +57,7 @@ func TestRunPipe(t *testing.T) {
 							Builds:       []string{"default"},
 							NameTemplate: defaultNameTemplate,
 							Files: []string{
-								"README.*",
+								"README.{{.Os}}.*",
 								"./foo/**/*",
 							},
 							FormatOverrides: []config.FormatOverride{
@@ -143,16 +146,16 @@ func TestRunPipe(t *testing.T) {
 
 			if format == "tar.gz" {
 				// Check archive contents
-				for _, name := range []string{
-					"foobar_0.0.1_darwin_amd64.tar.gz",
-					"foobar_0.0.1_linux_386.tar.gz",
-					"foobar_0.0.1_linux_armv7.tar.gz",
-					"foobar_0.0.1_linux_mips_softfloat.tar.gz",
+				for name, os := range map[string]string{
+					"foobar_0.0.1_darwin_amd64.tar.gz":         "darwin",
+					"foobar_0.0.1_linux_386.tar.gz":            "linux",
+					"foobar_0.0.1_linux_armv7.tar.gz":          "linux",
+					"foobar_0.0.1_linux_mips_softfloat.tar.gz": "linux",
 				} {
 					require.Equal(
 						t,
 						[]string{
-							"README.md",
+							fmt.Sprintf("README.%s.md", os),
 							"foo/bar",
 							"foo/bar/foobar",
 							"foo/bar/foobar/blah.txt",
@@ -166,7 +169,7 @@ func TestRunPipe(t *testing.T) {
 				require.Equal(
 					t,
 					[]string{
-						"README.md",
+						"README.windows.md",
 						"foo/bar/foobar/blah.txt",
 						"mybin.exe",
 					},
@@ -372,6 +375,44 @@ func TestRunPipeInvalidNameTemplate(t *testing.T) {
 	require.EqualError(t, Pipe{}.Run(ctx), `template: tmpl:1: unexpected "}" in operand`)
 }
 
+func TestRunPipeInvalidFilesNameTemplate(t *testing.T) {
+	folder, back := testlib.Mktmp(t)
+	defer back()
+	var dist = filepath.Join(folder, "dist")
+	require.NoError(t, os.Mkdir(dist, 0755))
+	require.NoError(t, os.Mkdir(filepath.Join(dist, "darwinamd64"), 0755))
+	_, err := os.Create(filepath.Join(dist, "darwinamd64", "mybin"))
+	require.NoError(t, err)
+	var ctx = context.New(
+		config.Project{
+			Dist: dist,
+			Archives: []config.Archive{
+				{
+					Builds:       []string{"default"},
+					NameTemplate: "foo",
+					Format:       "zip",
+					Files: []string{
+						"{{.asdsd}",
+					},
+				},
+			},
+		},
+	)
+	ctx.Git.CurrentTag = "v0.0.1"
+	ctx.Artifacts.Add(&artifact.Artifact{
+		Goos:   "darwin",
+		Goarch: "amd64",
+		Name:   "mybin",
+		Path:   filepath.Join("dist", "darwinamd64", "mybin"),
+		Type:   artifact.Binary,
+		Extra: map[string]interface{}{
+			"Binary": "mybin",
+			"ID":     "default",
+		},
+	})
+	require.EqualError(t, Pipe{}.Run(ctx), `failed to find files to archive: failed to apply template {{.asdsd}: template: tmpl:1: unexpected "}" in operand`)
+}
+
 func TestRunPipeInvalidWrapInDirectoryTemplate(t *testing.T) {
 	folder, back := testlib.Mktmp(t)
 	defer back()
diff --git a/internal/pipe/artifactory/artifactory_test.go b/internal/pipe/artifactory/artifactory_test.go
index 6694370d..0cf28347 100644
--- a/internal/pipe/artifactory/artifactory_test.go
+++ b/internal/pipe/artifactory/artifactory_test.go
@@ -634,7 +634,7 @@ func TestRunPipe_UnparsableTarget(t *testing.T) {
 	})
 
 	assert.NoError(t, Pipe{}.Default(ctx))
-	assert.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: parse ://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin: missing protocol scheme`)
+	assert.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: parse "://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin": missing protocol scheme`)
 }
 
 func TestRunPipe_SkipWhenPublishFalse(t *testing.T) {
diff --git a/internal/pipe/snapcraft/snapcraft_test.go b/internal/pipe/snapcraft/snapcraft_test.go
index d191f444..395ed8f7 100644
--- a/internal/pipe/snapcraft/snapcraft_test.go
+++ b/internal/pipe/snapcraft/snapcraft_test.go
@@ -9,6 +9,7 @@ import (
 
 	"github.com/goreleaser/goreleaser/internal/artifact"
 	"github.com/goreleaser/goreleaser/internal/pipe"
+	"github.com/goreleaser/goreleaser/internal/testlib"
 	"github.com/goreleaser/goreleaser/pkg/config"
 	"github.com/goreleaser/goreleaser/pkg/context"
 	"github.com/stretchr/testify/assert"
@@ -355,6 +356,19 @@ func TestPublish(t *testing.T) {
 	assert.Contains(t, err.Error(), "failed to push nope.snap package")
 }
 
+func TestPublishSkip(t *testing.T) {
+	var ctx = context.New(config.Project{})
+	ctx.SkipPublish = true
+	ctx.Artifacts.Add(&artifact.Artifact{
+		Name:   "mybin",
+		Path:   "nope.snap",
+		Goarch: "amd64",
+		Goos:   "linux",
+		Type:   artifact.PublishableSnapcraft,
+	})
+	testlib.AssertSkipped(t, Pipe{}.Publish(ctx))
+}
+
 func TestDefaultSet(t *testing.T) {
 	var ctx = context.New(config.Project{
 		Snapcrafts: []config.Snapcraft{
diff --git a/internal/pipe/upload/upload_test.go b/internal/pipe/upload/upload_test.go
index a337fd0b..865bda97 100644
--- a/internal/pipe/upload/upload_test.go
+++ b/internal/pipe/upload/upload_test.go
@@ -550,7 +550,7 @@ func TestRunPipe_UnparsableTarget(t *testing.T) {
 		Type:   artifact.UploadableBinary,
 	})
 
-	assert.EqualError(t, Pipe{}.Publish(ctx), `upload: upload failed: parse ://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin: missing protocol scheme`)
+	assert.EqualError(t, Pipe{}.Publish(ctx), `upload: upload failed: parse "://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin": missing protocol scheme`)
 }
 
 func TestRunPipe_SkipWhenPublishFalse(t *testing.T) {
diff --git a/main_test.go b/main_test.go
index bc7618d7..ff7dc9cf 100644
--- a/main_test.go
+++ b/main_test.go
@@ -231,7 +231,7 @@ func createMainGo(t *testing.T) {
 func goModInit(t *testing.T) {
 	createFile(t, "go.mod", `module foo
 
-go 1.13
+go 1.14
 `)
 }