1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00

feat: remove :latest imgs from release notes (#2287)

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2021-06-08 11:11:27 -03:00 committed by GitHub
parent f285db2742
commit b53dbb89d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package release
import (
"bytes"
"strings"
"text/template"
"github.com/goreleaser/goreleaser/internal/artifact"
@ -21,15 +22,25 @@ const bodyTemplateText = `{{ with .Header }}{{ . }}{{ "\n" }}{{ end }}
{{- with .Footer }}{{ "\n" }}{{ . }}{{ end }}
`
func isLatest(img string) bool {
return strings.HasSuffix(img, ":latest") || !strings.Contains(img, ":")
}
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
var out bytes.Buffer
// nolint:prealloc
var dockers []string
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerManifest)).List() {
if isLatest(a.Name) {
continue
}
dockers = append(dockers, a.Name)
}
if len(dockers) == 0 {
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() {
if isLatest(a.Name) {
continue
}
dockers = append(dockers, a.Name)
}
}

View File

@ -17,6 +17,7 @@ func TestDescribeBody(t *testing.T) {
for _, d := range []string{
"goreleaser/goreleaser:0.40.0",
"goreleaser/goreleaser:latest",
"goreleaser/goreleaser",
"goreleaser/godownloader:v0.1.0",
} {
ctx.Artifacts.Add(&artifact.Artifact{
@ -94,7 +95,7 @@ func TestDescribeBodyWithHeaderAndFooter(t *testing.T) {
})
ctx.ReleaseNotes = changelog
ctx.Artifacts.Add(&artifact.Artifact{
Name: "goreleaser/goreleaser:latest",
Name: "goreleaser/goreleaser:v1.2.3",
Type: artifact.DockerImage,
})
out, err := describeBody(ctx)

View File

@ -4,5 +4,4 @@ feature2: other description
## Docker images
- `docker pull goreleaser/goreleaser:0.40.0`
- `docker pull goreleaser/goreleaser:latest`
- `docker pull goreleaser/godownloader:v0.1.0`

View File

@ -4,5 +4,4 @@ feature2: other description
## Docker images
- `docker pull goreleaser/goreleaser:0.40.0`
- `docker pull goreleaser/goreleaser:latest`
- `docker pull goreleaser/godownloader:v0.1.0`

View File

@ -6,7 +6,7 @@ feature2: other description
## Docker images
- `docker pull goreleaser/goreleaser:latest`
- `docker pull goreleaser/goreleaser:v1.2.3`
---