Repository: goreleaser/goreleaser
Pull request #1979 (2020-12-29 17:28:12)

feat: simplify docker images
- we don't need the `latest-$arch` imgs as it handled by the manifest
- the v0.X imgs are never used anyway, removing

We'll now only have `latest` and `v0.x.y` images.

vercel[bot]: This pull request is being automatically deployed with Vercel ([learn more](https://vercel.link/github-learn-more)).  
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: [https://vercel.com/goreleaser/goreleaser/mz1xy1r6a](https://vercel.com/goreleaser/goreleaser/mz1xy1r6a)  
✅ Preview: [https://goreleaser-git-images.goreleaser.vercel.app](https://goreleaser-git-images.goreleaser.vercel.app)


codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1979?src=pr&el=h1) Report
> Merging [#1979](https://codecov.io/gh/goreleaser/goreleaser/pull/1979?src=pr&el=desc) (7a4c5b9) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/1b0b6be8c577be4994cc526c0a7e25d780988370?el=desc) (1b0b6be) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master    #1979   +/-   ##
=======================================
  Coverage   82.65%   82.65%           
=======================================
  Files          74       74           
  Lines        3984     3984           
=======================================
  Hits         3293     3293           
  Misses        562      562           
  Partials      129      129           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1979?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/1979?src=pr&el=footer). Last update [1b0b6be...7a4c5b9](https://codecov.io/gh/goreleaser/goreleaser/pull/1979?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

crazy-max: @caarlos0 If you want some hints about image versioning, you can take a look at https://github.com/crazy-max/ghaction-docker-meta#semver

Patch:
diff --git a/.goreleaser.yml b/.goreleaser.yml
index 01deb0ba..09974155 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -37,10 +37,6 @@ dockers:
 - image_templates:
   - 'goreleaser/goreleaser:{{ .Tag }}-amd64'
   - 'ghcr.io/goreleaser/goreleaser:{{ .Tag }}-amd64'
-  - 'goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}-amd64'
-  - 'ghcr.io/goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}-amd64'
-  - 'goreleaser/goreleaser:latest-amd64'
-  - 'ghcr.io/goreleaser/goreleaser:latest-amd64'
   dockerfile: Dockerfile
   binaries:
   - goreleaser
@@ -57,10 +53,6 @@ dockers:
 - image_templates:
   - 'goreleaser/goreleaser:{{ .Tag }}-arm64v8'
   - 'ghcr.io/goreleaser/goreleaser:{{ .Tag }}-arm64v8'
-  - 'goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}-arm64v8'
-  - 'ghcr.io/goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}-arm64v8'
-  - 'goreleaser/goreleaser:latest-arm64v8'
-  - 'ghcr.io/goreleaser/goreleaser:latest-arm64v8'
   dockerfile: Dockerfile
   binaries:
   - goreleaser
@@ -84,22 +76,14 @@ docker_manifests:
   image_templates:
   - 'ghcr.io/goreleaser/goreleaser:{{ .Tag }}-amd64'
   - 'ghcr.io/goreleaser/goreleaser:{{ .Tag }}-arm64v8'
-- name_template: 'goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}'
-  image_templates:
-  - 'goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}-amd64'
-  - 'goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}-arm64v8'
-- name_template: 'ghcr.io/goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}'
-  image_templates:
-  - 'ghcr.io/goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}-amd64'
-  - 'ghcr.io/goreleaser/goreleaser:v{{ .Major }}.{{ .Minor }}-arm64v8'
 - name_template: 'goreleaser/goreleaser:latest'
   image_templates:
-  - 'goreleaser/goreleaser:latest-amd64'
-  - 'goreleaser/goreleaser:latest-arm64v8'
+  - 'goreleaser/goreleaser:{{ .Tag }}-amd64'
+  - 'goreleaser/goreleaser:{{ .Tag }}-arm64v8'
 - name_template: 'ghcr.io/goreleaser/goreleaser:latest'
   image_templates:
-  - 'ghcr.io/goreleaser/goreleaser:latest-amd64'
-  - 'ghcr.io/goreleaser/goreleaser:latest-arm64v8'
+  - 'ghcr.io/goreleaser/goreleaser:{{ .Tag }}-amd64'
+  - 'ghcr.io/goreleaser/goreleaser:{{ .Tag }}-arm64v8'
 archives:
   - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
     replacements:
diff --git a/go.mod b/go.mod
index 330c73e9..8f61c18d 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,7 @@ require (
 	github.com/golangci/golangci-lint v1.34.1
 	github.com/google/go-github/v28 v28.1.1
 	github.com/goreleaser/fileglob v0.3.1
-	github.com/goreleaser/nfpm/v2 v2.1.1
+	github.com/goreleaser/nfpm/v2 v2.1.2
 	github.com/imdario/mergo v0.3.11
 	github.com/jarcoal/httpmock v1.0.6
 	github.com/mattn/go-shellwords v1.0.10
diff --git a/go.sum b/go.sum
index bb6d0e09..7e6e5a46 100644
--- a/go.sum
+++ b/go.sum
@@ -321,7 +321,6 @@ github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d h1:pXTK/gkVNs7Zyy
 github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d/go.mod h1:ozx7R9SIwqmqf5pRP90DhR2Oay2UIjGuKheCBCNwAYU=
 github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a h1:iR3fYXUjHCR97qWS8ch1y9zPNsgXThGwjKPrYfqMPks=
 github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU=
-github.com/golangci/golangci-lint v1.34.0/go.mod h1:6Bnn7T0JYin7uukitgL6f9E9auQatlT0RMNOKG9lSHU=
 github.com/golangci/golangci-lint v1.34.1 h1:xf1yVlLBNeCIoOHWXhwqnUeaqzONllRSgiLSahNt0Mw=
 github.com/golangci/golangci-lint v1.34.1/go.mod h1:6Bnn7T0JYin7uukitgL6f9E9auQatlT0RMNOKG9lSHU=
 github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc h1:gLLhTLMk2/SutryVJ6D4VZCU3CUqr8YloG7FPIBWFpI=
@@ -403,8 +402,8 @@ github.com/goreleaser/chglog v0.1.2 h1:tdzAb/ILeMnphzI9zQ7Nkq+T8R9qyXli8GydD8plF
 github.com/goreleaser/chglog v0.1.2/go.mod h1:tTZsFuSZK4epDXfjMkxzcGbrIOXprf0JFp47BjIr3B8=
 github.com/goreleaser/fileglob v0.3.1 h1:OTFDWqUUHjQazk2N5GdUqEbqT/grBnRARaAXsV07q1Y=
 github.com/goreleaser/fileglob v0.3.1/go.mod h1:kNcPrPzjCp+Ox3jmXLU5QEsjhqrtLBm6OnXAif8KRl8=
-github.com/goreleaser/nfpm/v2 v2.1.1 h1:AQfPJhXawspi1HQ+MwciD5Qx3PmPooBcflSOj6MFHII=
-github.com/goreleaser/nfpm/v2 v2.1.1/go.mod h1:t0a9poc7g2hnagNncDjGU+4wZJ5d1oh2D2BmJhLrN7I=
+github.com/goreleaser/nfpm/v2 v2.1.2 h1:3F3oU10jT83qO6Ee+8N70h0ZfT1p0WHkdsEUtF3n9zI=
+github.com/goreleaser/nfpm/v2 v2.1.2/go.mod h1:WtPzYQh+Ls57prS9RzXegrGejqILUS1aZibXHTTJ8eI=
 github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE=
diff --git a/internal/pipe/docker/manifest.go b/internal/pipe/docker/manifest.go
index da7fe456..64342bc7 100644
--- a/internal/pipe/docker/manifest.go
+++ b/internal/pipe/docker/manifest.go
@@ -27,7 +27,7 @@ func (ManifestPipe) Publish(ctx *context.Context) error {
 	if ctx.SkipPublish {
 		return pipe.ErrSkipPublishEnabled
 	}
-	var g = semerrgroup.NewSkipAware(semerrgroup.New(ctx.Parallelism))
+	var g = semerrgroup.NewSkipAware(semerrgroup.New(1))
 	for _, manifest := range ctx.Config.DockerManifests {
 		manifest := manifest
 		g.Go(func() error {
diff --git a/internal/pipe/nfpm/nfpm.go b/internal/pipe/nfpm/nfpm.go
index 8055e030..56bc695d 100644
--- a/internal/pipe/nfpm/nfpm.go
+++ b/internal/pipe/nfpm/nfpm.go
@@ -186,7 +186,9 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries
 	}
 
 	var contents files.Contents
-	copy(overridden.Contents, contents)
+	for _, f := range overridden.Contents {
+		contents = append(contents, f)
+	}
 
 	// FPM meta package should not contain binaries at all
 	if !fpm.Meta {
@@ -202,7 +204,7 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries
 		}
 	}
 
-	log.WithField("files", contents).Debug("all archive files")
+	log.WithField("files", destinations(contents)).Debug("all archive files")
 
 	var info = &nfpm.Info{
 		Arch:            arch,
@@ -318,6 +320,14 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries
 	return nil
 }
 
+func destinations(contents files.Contents) []string {
+	var result = make([]string, 0, len(contents))
+	for _, f := range contents {
+		result = append(result, f.Destination)
+	}
+	return result
+}
+
 func getPassphraseFromEnv(ctx *context.Context, packager string, nfpmID string) string {
 	var passphrase string
 
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 143ada66..85eac5b2 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -339,8 +339,8 @@ type NFPMRPM struct {
 	Summary              string            `yaml:"summary,omitempty"`
 	Group                string            `yaml:"group,omitempty"`
 	Compression          string            `yaml:"compression,omitempty"`
-	ConfigNoReplaceFiles map[string]string `yaml:"config_noreplace_files,omitempty"` // depreacated: use contents instead
-	GhostFiles           []string          `yaml:"ghost_files,omitempty"`            // depreacated: use contents instead
+	ConfigNoReplaceFiles map[string]string `yaml:"config_noreplace_files,omitempty"` // deprecated: use contents instead
+	GhostFiles           []string          `yaml:"ghost_files,omitempty"`            // deprecated: use contents instead
 	Signature            NFPMRPMSignature  `yaml:"signature,omitempty"`
 }
 
diff --git a/www/docs/customization/nfpm.md b/www/docs/customization/nfpm.md
index 5cff8a60..82431988 100644
--- a/www/docs/customization/nfpm.md
+++ b/www/docs/customization/nfpm.md
@@ -131,12 +131,13 @@ nfpms:
         dst: /etc/foo.conf
         type: config
 
-      # Simple symlink
-      - src: /sbin/foo # link name
-        dst: /usr/local/bin/foo # real location
+      # Simple symlink.
+      # Corresponds to `ln -s /sbin/foo /usr/local/bin/foo`
+      - src: /sbin/foo
+        dst: /usr/local/bin/foo
         type: "symlink"
 
-      # Corresponds to %config(noreplace) if the packager is rpm, otherwise it is just a config file
+      # Corresponds to `%config(noreplace)` if the packager is rpm, otherwise it is just a config file
       - src: path/to/local/bar.conf
         dst: /etc/bar.conf
         type: "config|noreplace"


Test patch:
diff --git a/internal/pipe/nfpm/nfpm_test.go b/internal/pipe/nfpm/nfpm_test.go
index 7591d767..ae82aea4 100644
--- a/internal/pipe/nfpm/nfpm_test.go
+++ b/internal/pipe/nfpm/nfpm_test.go
@@ -158,9 +158,15 @@ func TestRunPipe(t *testing.T) {
 		require.NotEmpty(t, format)
 		require.Equal(t, pkg.Name, "mybin_1.0.0_Tux_"+pkg.Goarch+"-10-20."+format)
 		require.Equal(t, pkg.ExtraOr("ID", ""), "someid")
+		require.ElementsMatch(t, []string{
+			"/usr/share/testfile.txt",
+			"/etc/nope.conf",
+			"/etc/nope-rpm.conf",
+			"/etc/nope2.conf",
+			"/usr/bin/mybin",
+		}, destinations(pkg.ExtraOr("Files", files.Contents{}).(files.Contents)))
 	}
 	require.Len(t, ctx.Config.NFPMs[0].Contents, 4, "should not modify the config file list")
-
 }
 
 func TestInvalidNameTemplate(t *testing.T) {
@@ -725,17 +731,14 @@ func TestMeta(t *testing.T) {
 		require.NotEmpty(t, format)
 		require.Equal(t, pkg.Name, "mybin_1.0.0_Tux_"+pkg.Goarch+"-10-20."+format)
 		require.Equal(t, pkg.ExtraOr("ID", ""), "someid")
+		require.ElementsMatch(t, []string{
+			"/usr/share/testfile.txt",
+			"/etc/nope.conf",
+			"/etc/nope-rpm.conf",
+		}, destinations(pkg.ExtraOr("Files", files.Contents{}).(files.Contents)))
 	}
 
 	require.Len(t, ctx.Config.NFPMs[0].Contents, 3, "should not modify the config file list")
-
-	// ensure that no binaries added
-	for _, pkg := range packages {
-		contents := pkg.ExtraOr("Files", files.Contents{}).(files.Contents)
-		for _, f := range contents {
-			require.NotEqual(t, "/usr/bin/mybin", f.Destination, "binary file should not be added")
-		}
-	}
 }
 
 func TestSkipSign(t *testing.T) {