Repository: goreleaser/goreleaser
Pull request #1925 (2020-11-28 20:56:30)

feat: add docker manifests to release notes
refs https://github.com/goreleaser/goreleaser/pull/1923

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


codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1925?src=pr&el=h1) Report
> Merging [#1925](https://codecov.io/gh/goreleaser/goreleaser/pull/1925?src=pr&el=desc) (e1c3bf9) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/1da3eeb5dc4351bc7d61ca1a1a3d9c68609edbc0?el=desc) (1da3eeb) will **decrease** coverage by `0.06%`.
> The diff coverage is `60.00%`.

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

```diff
@@            Coverage Diff             @@
##           master    #1925      +/-   ##
==========================================
- Coverage   81.89%   81.83%   -0.07%     
==========================================
  Files          74       74              
  Lines        3933     3942       +9     
==========================================
+ Hits         3221     3226       +5     
- Misses        583      586       +3     
- Partials      129      130       +1     
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/1925?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [internal/artifact/artifact.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1925/diff?src=pr&el=tree#diff-aW50ZXJuYWwvYXJ0aWZhY3QvYXJ0aWZhY3QuZ28=) | `75.72% <0.00%> (-1.50%)` | :arrow_down: |
| [internal/pipe/docker/manifest.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1925/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9kb2NrZXIvbWFuaWZlc3QuZ28=) | `93.22% <71.42%> (-3.01%)` | :arrow_down: |
| [internal/pipe/release/body.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1925/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9yZWxlYXNlL2JvZHkuZ28=) | `100.00% <100.00%> (ø)` | |

------

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


Patch:
diff --git a/internal/artifact/artifact.go b/internal/artifact/artifact.go
index e11302a8..15f96f06 100644
--- a/internal/artifact/artifact.go
+++ b/internal/artifact/artifact.go
@@ -40,6 +40,8 @@ const (
 	PublishableDockerImage
 	// DockerImage is a published Docker image.
 	DockerImage
+	// DockerManifest is a published Docker manifest.
+	DockerManifest
 	// Checksum is a checksums file.
 	Checksum
 	// Signature is a signature file.
@@ -60,6 +62,8 @@ func (t Type) String() string {
 		return "Linux Package"
 	case PublishableDockerImage, DockerImage:
 		return "Docker Image"
+	case DockerManifest:
+		return "Docker Manifest"
 	case PublishableSnapcraft, Snapcraft:
 		return "Snap"
 	case Checksum:
diff --git a/internal/pipe/docker/manifest.go b/internal/pipe/docker/manifest.go
index b6f783aa..da7fe456 100644
--- a/internal/pipe/docker/manifest.go
+++ b/internal/pipe/docker/manifest.go
@@ -6,6 +6,7 @@ import (
 	"strings"
 
 	"github.com/apex/log"
+	"github.com/goreleaser/goreleaser/internal/artifact"
 	"github.com/goreleaser/goreleaser/internal/pipe"
 	"github.com/goreleaser/goreleaser/internal/semerrgroup"
 	"github.com/goreleaser/goreleaser/internal/tmpl"
@@ -41,6 +42,11 @@ func (ManifestPipe) Publish(ctx *context.Context) error {
 			if err := dockerManifestCreate(ctx, name, images, manifest.CreateFlags); err != nil {
 				return err
 			}
+			ctx.Artifacts.Add(&artifact.Artifact{
+				Type: artifact.DockerManifest,
+				Name: name,
+				Path: name,
+			})
 			return dockerManifestPush(ctx, name, manifest.PushFlags)
 		})
 	}
diff --git a/internal/pipe/release/body.go b/internal/pipe/release/body.go
index 7b545013..c73aad28 100644
--- a/internal/pipe/release/body.go
+++ b/internal/pipe/release/body.go
@@ -23,6 +23,9 @@ 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() {
+		dockers = append(dockers, a.Name)
+	}
 	for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() {
 		dockers = append(dockers, a.Name)
 	}


Test patch:
diff --git a/internal/artifact/artifact_test.go b/internal/artifact/artifact_test.go
index ba468937..6ae69171 100644
--- a/internal/artifact/artifact_test.go
+++ b/internal/artifact/artifact_test.go
@@ -288,3 +288,28 @@ func TestByFormats(t *testing.T) {
 	require.Len(t, artifacts.Filter(ByFormats("zip")).items, 2)
 	require.Len(t, artifacts.Filter(ByFormats("zip", "tar.gz")).items, 3)
 }
+
+func TestTypeToString(t *testing.T) {
+	for _, a := range []Type{
+		UploadableArchive,
+		UploadableBinary,
+		UploadableFile,
+		Binary,
+		LinuxPackage,
+		PublishableSnapcraft,
+		Snapcraft,
+		PublishableDockerImage,
+		DockerImage,
+		DockerManifest,
+		Checksum,
+		Signature,
+		UploadableSourceArchive,
+	} {
+		t.Run(a.String(), func(t *testing.T) {
+			require.NotEqual(t, "unknown", a.String())
+		})
+	}
+	t.Run("unknown", func(t *testing.T) {
+		require.Equal(t, "unknown", Type(9999).String())
+	})
+}
diff --git a/internal/pipe/docker/docker_test.go b/internal/pipe/docker/docker_test.go
index 40e5ede2..c4d0dae4 100644
--- a/internal/pipe/docker/docker_test.go
+++ b/internal/pipe/docker/docker_test.go
@@ -152,10 +152,10 @@ func TestRunPipe(t *testing.T) {
 			},
 			manifests: []config.DockerManifest{
 				{
-					NameTemplate: registry + "goreleaser/test_multiarch_fail:test",
-					ImageTemplates:   []string{registry + "goreleaser/test_multiarch_fail:latest-amd64"},
-					CreateFlags:      []string{"--insecure"},
-					PushFlags:        []string{"--insecure"},
+					NameTemplate:   registry + "goreleaser/test_multiarch_fail:test",
+					ImageTemplates: []string{registry + "goreleaser/test_multiarch_fail:latest-amd64"},
+					CreateFlags:    []string{"--insecure"},
+					PushFlags:      []string{"--insecure"},
 				},
 			},
 			expect:              []string{registry + "goreleaser/test_multiarch_fail:latest-arm64v8"},
@@ -176,8 +176,8 @@ func TestRunPipe(t *testing.T) {
 			},
 			manifests: []config.DockerManifest{
 				{
-					NameTemplate: registry + "goreleaser/test_multiarch_manifest_tmpl_error:{{ .Goos }",
-					ImageTemplates:   []string{registry + "goreleaser/test_multiarch_manifest_tmpl_error"},
+					NameTemplate:   registry + "goreleaser/test_multiarch_manifest_tmpl_error:{{ .Goos }",
+					ImageTemplates: []string{registry + "goreleaser/test_multiarch_manifest_tmpl_error"},
 				},
 			},
 			expect:              []string{registry + "goreleaser/test_multiarch_manifest_tmpl_error"},
@@ -198,8 +198,8 @@ func TestRunPipe(t *testing.T) {
 			},
 			manifests: []config.DockerManifest{
 				{
-					NameTemplate: registry + "goreleaser/test_multiarch_img_tmpl_error",
-					ImageTemplates:   []string{registry + "goreleaser/test_multiarch_img_tmpl_error:{{ .Goos }"},
+					NameTemplate:   registry + "goreleaser/test_multiarch_img_tmpl_error",
+					ImageTemplates: []string{registry + "goreleaser/test_multiarch_img_tmpl_error:{{ .Goos }"},
 				},
 			},
 			expect:              []string{registry + "goreleaser/test_multiarch_img_tmpl_error"},
@@ -220,8 +220,8 @@ func TestRunPipe(t *testing.T) {
 			},
 			manifests: []config.DockerManifest{
 				{
-					NameTemplate: "  ",
-					ImageTemplates:   []string{registry + "goreleaser/test_multiarch_no_mainifest_name"},
+					NameTemplate:   "  ",
+					ImageTemplates: []string{registry + "goreleaser/test_multiarch_no_mainifest_name"},
 				},
 			},
 			expect:              []string{registry + "goreleaser/test_multiarch_no_mainifest_name"},
@@ -242,8 +242,8 @@ func TestRunPipe(t *testing.T) {
 			},
 			manifests: []config.DockerManifest{
 				{
-					NameTemplate: "ignored",
-					ImageTemplates:   []string{" ", "   ", ""},
+					NameTemplate:   "ignored",
+					ImageTemplates: []string{" ", "   ", ""},
 				},
 			},
 			expect:              []string{registry + "goreleaser/test_multiarch_no_mainifest_images"},
diff --git a/internal/pipe/release/body_test.go b/internal/pipe/release/body_test.go
index da1af5b1..080cd1c4 100644
--- a/internal/pipe/release/body_test.go
+++ b/internal/pipe/release/body_test.go
@@ -21,6 +21,19 @@ func TestDescribeBody(t *testing.T) {
 		"goreleaser/goreleaser:0.40.0",
 		"goreleaser/goreleaser:latest",
 		"goreleaser/godownloader:v0.1.0",
+	} {
+		ctx.Artifacts.Add(&artifact.Artifact{
+			Name: d,
+			Type: artifact.DockerManifest,
+		})
+	}
+	for _, d := range []string{
+		"goreleaser/goreleaser:0.40.0-amd64",
+		"goreleaser/goreleaser:latest-amd64",
+		"goreleaser/godownloader:v0.1.0-amd64",
+		"goreleaser/goreleaser:0.40.0-arm64",
+		"goreleaser/goreleaser:latest-arm64",
+		"goreleaser/godownloader:v0.1.0-arm64",
 	} {
 		ctx.Artifacts.Add(&artifact.Artifact{
 			Name: d,
diff --git a/internal/pipe/release/testdata/release1.golden b/internal/pipe/release/testdata/release1.golden
index 1005de7a..50aa260e 100755
--- a/internal/pipe/release/testdata/release1.golden
+++ b/internal/pipe/release/testdata/release1.golden
@@ -6,3 +6,9 @@ feature2: other description
 - `docker pull goreleaser/goreleaser:0.40.0`
 - `docker pull goreleaser/goreleaser:latest`
 - `docker pull goreleaser/godownloader:v0.1.0`
+- `docker pull goreleaser/goreleaser:0.40.0-amd64`
+- `docker pull goreleaser/goreleaser:latest-amd64`
+- `docker pull goreleaser/godownloader:v0.1.0-amd64`
+- `docker pull goreleaser/goreleaser:0.40.0-arm64`
+- `docker pull goreleaser/goreleaser:latest-arm64`
+- `docker pull goreleaser/godownloader:v0.1.0-arm64`