diff --git a/internal/pipe/release/body.go b/internal/pipe/release/body.go index 5e775041c..05c7c720b 100644 --- a/internal/pipe/release/body.go +++ b/internal/pipe/release/body.go @@ -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) } } diff --git a/internal/pipe/release/body_test.go b/internal/pipe/release/body_test.go index 5546de20d..440d2da8d 100644 --- a/internal/pipe/release/body_test.go +++ b/internal/pipe/release/body_test.go @@ -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) diff --git a/internal/pipe/release/testdata/TestDescribeBody.golden b/internal/pipe/release/testdata/TestDescribeBody.golden index 1005de7a8..2aba26e72 100644 --- a/internal/pipe/release/testdata/TestDescribeBody.golden +++ b/internal/pipe/release/testdata/TestDescribeBody.golden @@ -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` diff --git a/internal/pipe/release/testdata/TestDescribeBodyWithDockerManifest.golden b/internal/pipe/release/testdata/TestDescribeBodyWithDockerManifest.golden index 1005de7a8..2aba26e72 100644 --- a/internal/pipe/release/testdata/TestDescribeBodyWithDockerManifest.golden +++ b/internal/pipe/release/testdata/TestDescribeBodyWithDockerManifest.golden @@ -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` diff --git a/internal/pipe/release/testdata/TestDescribeBodyWithHeaderAndFooter.golden b/internal/pipe/release/testdata/TestDescribeBodyWithHeaderAndFooter.golden index 3cfbe383f..12f317670 100644 --- a/internal/pipe/release/testdata/TestDescribeBodyWithHeaderAndFooter.golden +++ b/internal/pipe/release/testdata/TestDescribeBodyWithHeaderAndFooter.golden @@ -6,7 +6,7 @@ feature2: other description ## Docker images -- `docker pull goreleaser/goreleaser:latest` +- `docker pull goreleaser/goreleaser:v1.2.3` ---