Repository: goreleaser/goreleaser
Pull request #1968 (2020-12-25 23:59:47)

feat: upgrade nfpm
upgrade nfpm again :) 

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/pzwjx38vj](https://vercel.com/goreleaser/goreleaser/pzwjx38vj)  
✅ Preview: [https://goreleaser-git-nfpm.goreleaser.vercel.app](https://goreleaser-git-nfpm.goreleaser.vercel.app)


codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1968?src=pr&el=h1) Report
> Merging [#1968](https://codecov.io/gh/goreleaser/goreleaser/pull/1968?src=pr&el=desc) (4cf5899) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/28562a319e8c9ffd4a11d51019959e32bfde0723?el=desc) (28562a3) will **decrease** coverage by `0.06%`.
> The diff coverage is `25.00%`.

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

```diff
@@            Coverage Diff             @@
##           master    #1968      +/-   ##
==========================================
- Coverage   82.61%   82.54%   -0.07%     
==========================================
  Files          74       74              
  Lines        3975     3977       +2     
==========================================
- Hits         3284     3283       -1     
- Misses        562      564       +2     
- Partials      129      130       +1     
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/1968?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/config/config.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1968/diff?src=pr&el=tree#diff-cGtnL2NvbmZpZy9jb25maWcuZ28=) | `93.75% <ø> (ø)` | |
| [internal/pipe/nfpm/nfpm.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1968/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9uZnBtL25mcG0uZ28=) | `93.83% <25.00%> (-1.38%)` | :arrow_down: |

------

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


Patch:
diff --git a/go.mod b/go.mod
index 410ad213..782546d7 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,7 @@ require (
 	github.com/golangci/golangci-lint v1.33.0
 	github.com/google/go-github/v28 v28.1.1
 	github.com/goreleaser/fileglob v0.3.1
-	github.com/goreleaser/nfpm/v2 v2.0.0
+	github.com/goreleaser/nfpm/v2 v2.1.0
 	github.com/imdario/mergo v0.3.11
 	github.com/jarcoal/httpmock v1.0.6
 	github.com/mattn/go-shellwords v1.0.10
@@ -30,5 +30,3 @@ require (
 
 // https://github.com/mattn/go-shellwords/pull/39
 replace github.com/mattn/go-shellwords => github.com/caarlos0/go-shellwords v1.0.11
-
-replace github.com/google/rpmpack => github.com/djgilcrease/rpmpack v0.0.0-20201221224521-5ac1d3b45cee
diff --git a/go.sum b/go.sum
index c007238d..4d359691 100644
--- a/go.sum
+++ b/go.sum
@@ -198,8 +198,6 @@ github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TR
 github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
 github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U=
 github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE=
-github.com/djgilcrease/rpmpack v0.0.0-20201221224521-5ac1d3b45cee h1:2u15NiDCpocHztN+7rvPuklKbmzeZDXmRu6qk49bll8=
-github.com/djgilcrease/rpmpack v0.0.0-20201221224521-5ac1d3b45cee/go.mod h1:+y9lKiqDhR4zkLl+V9h4q0rdyrYVsWWm6LLCQP33DIk=
 github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
 github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -380,6 +378,8 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf
 github.com/google/pprof v0.0.0-20200905233945-acf8798be1f7/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
 github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
+github.com/google/rpmpack v0.0.0-20201225075926-0a97c2c4b688 h1:jyGRCFMyDK/gKe6QRZQWci5+wEUBFElvxLHs3iwO3hY=
+github.com/google/rpmpack v0.0.0-20201225075926-0a97c2c4b688/go.mod h1:+y9lKiqDhR4zkLl+V9h4q0rdyrYVsWWm6LLCQP33DIk=
 github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
@@ -400,8 +400,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.0.0 h1:bsYhHEpJjLbgOuhKgPpdxVA6Ni7Zvrx6tRRkw3km2uo=
-github.com/goreleaser/nfpm/v2 v2.0.0/go.mod h1:CwZQFnLAUvqz3H1ijvb8SfTz1LYuw+DznSLOQ8uth8s=
+github.com/goreleaser/nfpm/v2 v2.1.0 h1:FumVnlopJ280VDfsLv89fqxcuk82UP+fdinnCqmden4=
+github.com/goreleaser/nfpm/v2 v2.1.0/go.mod h1:GCkOXaUGhQtItbYMqLso9oVIlsfF6NON8OnNJA3KB38=
 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/nfpm/nfpm.go b/internal/pipe/nfpm/nfpm.go
index 35190a03..8055e030 100644
--- a/internal/pipe/nfpm/nfpm.go
+++ b/internal/pipe/nfpm/nfpm.go
@@ -102,6 +102,10 @@ func (Pipe) Default(ctx *context.Context) error {
 			}
 			deprecate.Notice(ctx, "nfpms.rpm.config_noreplace_files")
 		}
+		if fpm.Deb.VersionMetadata != "" {
+			deprecate.Notice(ctx, "nfpms.deb.version_metadata")
+			fpm.VersionMetadata = fpm.Deb.VersionMetadata
+		}
 
 		if len(fpm.Builds) == 0 {
 			for _, b := range ctx.Config.Builds {
@@ -201,19 +205,21 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries
 	log.WithField("files", contents).Debug("all archive files")
 
 	var info = &nfpm.Info{
-		Arch:        arch,
-		Platform:    "linux",
-		Name:        fpm.PackageName,
-		Version:     ctx.Version,
-		Section:     "",
-		Priority:    "",
-		Epoch:       fpm.Epoch,
-		Release:     fpm.Release,
-		Maintainer:  fpm.Maintainer,
-		Description: fpm.Description,
-		Vendor:      fpm.Vendor,
-		Homepage:    fpm.Homepage,
-		License:     fpm.License,
+		Arch:            arch,
+		Platform:        "linux",
+		Name:            fpm.PackageName,
+		Version:         ctx.Version,
+		Section:         "",
+		Priority:        "",
+		Epoch:           fpm.Epoch,
+		Release:         fpm.Release,
+		Prerelease:      fpm.Prerelease,
+		VersionMetadata: fpm.VersionMetadata,
+		Maintainer:      fpm.Maintainer,
+		Description:     fpm.Description,
+		Vendor:          fpm.Vendor,
+		Homepage:        fpm.Homepage,
+		License:         fpm.License,
 		Overridables: nfpm.Overridables{
 			Conflicts:    overridden.Conflicts,
 			Depends:      overridden.Dependencies,
@@ -241,8 +247,7 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries
 					ActivateAwait:   overridden.Deb.Triggers.ActivateAwait,
 					ActivateNoAwait: overridden.Deb.Triggers.ActivateNoAwait,
 				},
-				Breaks:          overridden.Deb.Breaks,
-				VersionMetadata: overridden.Deb.VersionMetadata,
+				Breaks: overridden.Deb.Breaks,
 				Signature: nfpm.DebSignature{
 					KeyFile:       overridden.Deb.Signature.KeyFile,
 					KeyPassphrase: getPassphraseFromEnv(ctx, "DEB", fpm.ID),
diff --git a/pkg/config/config.go b/pkg/config/config.go
index d22b847e..143ada66 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -400,6 +400,8 @@ type NFPMOverridables struct {
 	PackageName      string            `yaml:"package_name,omitempty"`
 	Epoch            string            `yaml:"epoch,omitempty"`
 	Release          string            `yaml:"release,omitempty"`
+	Prerelease       string            `yaml:"prerelease,omitempty"`
+	VersionMetadata  string            `yaml:"version_metadata,omitempty"`
 	Replacements     map[string]string `yaml:",omitempty"`
 	Dependencies     []string          `yaml:",omitempty"`
 	Recommends       []string          `yaml:",omitempty"`
diff --git a/www/docs/customization/nfpm.md b/www/docs/customization/nfpm.md
index ee690e0a..5cff8a60 100644
--- a/www/docs/customization/nfpm.md
+++ b/www/docs/customization/nfpm.md
@@ -92,12 +92,20 @@ nfpms:
     # Override default /usr/local/bin destination for binaries
     bindir: /usr/bin
 
-    # Package epoch.
-    # Defaults to empty.
-    epoch: 1
+    # Version Epoch.
+    # Default is extracted from `version` if it is semver compatible.
+    epoch: 2
 
-    # Package release.
-    # Defaults to empty.
+    # Version Prerelease.
+    # Default is extracted from `version` if it is semver compatible.
+    prerelease: beta1
+
+    # Version Metadata (previously deb.metadata).
+    # Default is extracted from `version` if it is semver compatible.
+    # Setting metadata might interfere with version comparisons depending on the packager.
+    version_metadata: git
+
+    # Version Release.
     release: 1
 
     # Makes a meta package - an empty package that contains only supporting files and dependencies.
diff --git a/www/docs/deprecations.md b/www/docs/deprecations.md
index 15886666..d7a94453 100644
--- a/www/docs/deprecations.md
+++ b/www/docs/deprecations.md
@@ -149,6 +149,28 @@ Change this:
     ```
 
 
+### nfpms.deb.version_metadata
+
+> since 2020-12-21 (v0.149.0)
+
+`deb.version_metadata` is deprecated in favor of `version_metadata` (check [this page](https://goreleaser.com/customization/nfpm/) for more details):
+
+Change this:
+
+=== "Before"
+```yaml
+nfpms:
+-
+  deb:
+    version_metadata: beta1
+```
+
+=== "After"
+```yaml
+-
+  version_metadata: beta1
+```
+
 ### brews.github
 
 > since 2020-07-06 (v0.139.0)


Test patch:
diff --git a/internal/pipe/nfpm/nfpm_test.go b/internal/pipe/nfpm/nfpm_test.go
index 661302d5..c304cbc9 100644
--- a/internal/pipe/nfpm/nfpm_test.go
+++ b/internal/pipe/nfpm/nfpm_test.go
@@ -329,6 +329,9 @@ func TestDefaultDeprecatedOptions(t *testing.T) {
 								"testdata/testfile.txt": "/etc/foo_keep.conf",
 							},
 						},
+						Deb: config.NFPMDeb{
+							VersionMetadata: "beta1",
+						},
 					},
 				},
 			},
@@ -350,6 +353,7 @@ func TestDefaultDeprecatedOptions(t *testing.T) {
 	}, ctx.Config.NFPMs[0].Contents)
 	require.Equal(t, defaultNameTemplate, ctx.Config.NFPMs[0].FileNameTemplate)
 	require.Equal(t, ctx.Config.ProjectName, ctx.Config.NFPMs[0].PackageName)
+	require.Equal(t, "beta1", ctx.Config.NFPMs[0].VersionMetadata)
 }
 
 func TestDefaultSet(t *testing.T) {