Repository: goreleaser/nfpm (go)

Issue:
RPM cpio name contains the release twice
### What happened?

Hi, in v2.33.0, there is a new bug regarding the generation of an RPM.
using the minimal description file attached, the generated RPM is called `test-1.2.3-1.x86_64.rpm` (correct) but contains `test-1.2.3-1-1.x86_64.cpio` (not correct, release is used twice).
With v2.32.0, the rpm and cpio are correctly named.

### How can we reproduce this?

test.yaml :
```
name: "test"
version: 1.2.3
contents:
  - src: test
    dst: test
```
` go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.33.0`
` nfpm pkg --config test.yaml --packager rpm` 

### nfpm version

```bash
_____ ____  __  __
 _ __ |  ___|  _ \|  \/  |
| '_ \| |_  | |_) | |\/| |
| | | |  _| |  __/| |  | |
|_| |_|_|   |_|   |_|  |_|
nfpm: a simple and 0-dependencies deb, rpm, apk and arch linux packager written in Go
https://nfpm.goreleaser.com

GitVersion:    dev
GitCommit:     unknown
GitTreeState:  unknown
BuildDate:     unknown
BuiltBy:       unknown
GoVersion:     go1.21.1
Compiler:      gc
ModuleSum:     h1:yBv6jgkPwih4va/S42rceSjJ2Znt3Og/Ntc76oP0tfI=
Platform:      windows/amd64
```


### Search

- [X] I did search for other open and closed issues before opening this.

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Additional context

_No response_

Pull request:
fix(rpm): conventionalfilename
formatVersion is also used to set the version field of the RPM, which should not contain the release.

this fixes it, and the tests which were wrong.


closes #714 

Patch:
diff --git a/rpm/rpm.go b/rpm/rpm.go
index 311dce9..da47655 100644
--- a/rpm/rpm.go
+++ b/rpm/rpm.go
@@ -88,7 +88,13 @@ func (*RPM) ConventionalFileName(info *nfpm.Info) string {
 	info = setDefaults(info)
 
 	// name-version-release.architecture.rpm
-	return fmt.Sprintf("%s-%s.%s.rpm", info.Name, formatVersion(info), info.Arch)
+	return fmt.Sprintf(
+		"%s-%s-%s.%s.rpm",
+		info.Name,
+		formatVersion(info),
+		defaultTo(info.Release, "1"),
+		info.Arch,
+	)
 }
 
 // ConventionalExtension returns the file name conventionally used for RPM packages
@@ -266,7 +272,7 @@ func formatVersion(info *nfpm.Info) string {
 		version += "+" + info.VersionMetadata
 	}
 
-	return version + "-" + info.Release
+	return version
 }
 
 func defaultTo(in, def string) string {


Test patch:
diff --git a/rpm/rpm_test.go b/rpm/rpm_test.go
index 07ac2e0..a63090f 100644
--- a/rpm/rpm_test.go
+++ b/rpm/rpm_test.go
@@ -118,7 +118,7 @@ func TestRPM(t *testing.T) {
 
 	version, err := rpm.Header.GetString(rpmutils.VERSION)
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0-1", version)
+	require.Equal(t, "1.0.0", version)
 
 	release, err := rpm.Header.GetString(rpmutils.RELEASE)
 	require.NoError(t, err)
@@ -298,7 +298,7 @@ func TestWithRPMTags(t *testing.T) {
 
 	version, err := rpm.Header.GetString(rpmutils.VERSION)
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0-3", version)
+	require.Equal(t, "1.0.0", version)
 
 	release, err := rpm.Header.GetString(rpmutils.RELEASE)
 	require.NoError(t, err)
@@ -329,7 +329,7 @@ func TestRPMVersion(t *testing.T) {
 	info.Version = "1.0.0" //nolint:golint,goconst
 	meta, err := buildRPMMeta(info)
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0-1", meta.Version)
+	require.Equal(t, "1.0.0", meta.Version)
 	require.Equal(t, "1", meta.Release)
 }
 
@@ -339,7 +339,7 @@ func TestRPMVersionWithRelease(t *testing.T) {
 	info.Release = "2"
 	meta, err := buildRPMMeta(info)
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0-2", meta.Version)
+	require.Equal(t, "1.0.0", meta.Version)
 	require.Equal(t, "2", meta.Release)
 }
 
@@ -351,14 +351,14 @@ func TestRPMVersionWithPrerelease(t *testing.T) {
 	info.Prerelease = "rc1" // nolint:goconst
 	meta, err := buildRPMMeta(info)
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0~rc1-1", meta.Version)
+	require.Equal(t, "1.0.0~rc1", meta.Version)
 	require.Equal(t, "1", meta.Release)
 
 	info.Version = "1.0.0~rc1"
 	info.Prerelease = ""
 	meta, err = buildRPMMeta(info)
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0~rc1-1", meta.Version)
+	require.Equal(t, "1.0.0~rc1", meta.Version)
 	require.Equal(t, "1", meta.Release)
 }
 
@@ -371,7 +371,7 @@ func TestRPMVersionWithReleaseAndPrerelease(t *testing.T) {
 	info.Prerelease = "rc1"
 	meta, err := buildRPMMeta(info)
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0~rc1-2", meta.Version)
+	require.Equal(t, "1.0.0~rc1", meta.Version)
 	require.Equal(t, "2", meta.Release)
 
 	info.Version = "1.0.0~rc1"
@@ -379,7 +379,7 @@ func TestRPMVersionWithReleaseAndPrerelease(t *testing.T) {
 	info.Prerelease = ""
 	meta, err = buildRPMMeta(info)
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0~rc1-3", meta.Version)
+	require.Equal(t, "1.0.0~rc1", meta.Version)
 	require.Equal(t, "3", meta.Release)
 }
 
@@ -391,14 +391,16 @@ func TestRPMVersionWithVersionMetadata(t *testing.T) {
 	info.VersionMetadata = ""
 	meta, err := buildRPMMeta(info)
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0+meta-1", meta.Version)
+	require.Equal(t, "1.0.0+meta", meta.Version)
+	require.Equal(t, "1", meta.Release)
 
 	info.Version = "1.0.0"
 	info.VersionMetadata = "meta"
 	info.Release = "10"
 	meta, err = buildRPMMeta(nfpm.WithDefaults(info))
 	require.NoError(t, err)
-	require.Equal(t, "1.0.0+meta-10", meta.Version)
+	require.Equal(t, "1.0.0+meta", meta.Version)
+	require.Equal(t, "10", meta.Release)
 }
 
 func TestWithInvalidEpoch(t *testing.T) {
diff --git a/testdata/acceptance/rpm.dockerfile b/testdata/acceptance/rpm.dockerfile
index 0efaed5..1c64be2 100644
--- a/testdata/acceptance/rpm.dockerfile
+++ b/testdata/acceptance/rpm.dockerfile
@@ -123,7 +123,7 @@ RUN command -v zsh
 
 # ---- env-var-version test ----
 FROM min AS env-var-version
-ENV EXPECTVER="Version : 1.0.0~0.1.b1+git.abcdefgh-1" \
+ENV EXPECTVER="Version : 1.0.0~0.1.b1+git.abcdefgh" \
   EXPECTREL="Release : 1"
 RUN rpm -qpi /tmp/foo.rpm | sed -e 's/ \+/ /g' | grep "Version" > found.ver
 RUN rpm -qpi /tmp/foo.rpm | sed -e 's/ \+/ /g' | grep "Release" > found.rel