Repository: goreleaser/goreleaser
Pull request #3554 (2022-11-14 17:25:18)

fix: log when no artifacts are found for docker
refs #3545


Patch:
diff --git a/internal/pipe/checksums/checksums.go b/internal/pipe/checksums/checksums.go
index b5783766..4ec6f8a5 100644
--- a/internal/pipe/checksums/checksums.go
+++ b/internal/pipe/checksums/checksums.go
@@ -19,6 +19,10 @@ import (
 	"github.com/goreleaser/goreleaser/pkg/context"
 )
 
+const (
+	artifactChecksumExtra = "Checksum"
+)
+
 var (
 	errNoArtifacts = errors.New("there are no artifacts to sign")
 	lock           sync.Mutex
@@ -137,11 +141,17 @@ func refresh(ctx *context.Context, filepath string) error {
 	return err
 }
 
-func checksums(algorithm string, artifact *artifact.Artifact) (string, error) {
-	log.WithField("file", artifact.Name).Debug("checksumming")
-	sha, err := artifact.Checksum(algorithm)
+func checksums(algorithm string, a *artifact.Artifact) (string, error) {
+	log.WithField("file", a.Name).Debug("checksumming")
+	sha, err := a.Checksum(algorithm)
 	if err != nil {
 		return "", err
 	}
-	return fmt.Sprintf("%v  %v\n", sha, artifact.Name), nil
+
+	if a.Extra == nil {
+		a.Extra = make(artifact.Extras)
+	}
+	a.Extra[artifactChecksumExtra] = fmt.Sprintf("%s:%s", algorithm, sha)
+
+	return fmt.Sprintf("%v  %v\n", sha, a.Name), nil
 }
diff --git a/internal/pipe/docker/docker.go b/internal/pipe/docker/docker.go
index 108bc8ba..5d313e4a 100644
--- a/internal/pipe/docker/docker.go
+++ b/internal/pipe/docker/docker.go
@@ -20,7 +20,7 @@ import (
 
 const (
 	dockerConfigExtra = "DockerConfig"
-	dockerDigestExtra = "digest"
+	dockerDigestExtra = "Digest"
 
 	useBuildx = "buildx"
 	useDocker = "docker"
@@ -104,10 +104,12 @@ func (Pipe) Publish(ctx *context.Context) error {
 // Run the pipe.
 func (Pipe) Run(ctx *context.Context) error {
 	g := semerrgroup.NewSkipAware(semerrgroup.New(ctx.Parallelism))
-	for _, docker := range ctx.Config.Dockers {
+	for i, docker := range ctx.Config.Dockers {
+		i := i
 		docker := docker
 		g.Go(func() error {
-			log.WithField("docker", docker).Debug("looking for artifacts matching")
+			log := log.WithField("index", i)
+			log.Debug("looking for artifacts matching")
 			filters := []artifact.Filter{
 				artifact.ByGoos(docker.Goos),
 				artifact.ByGoarch(docker.Goarch),
@@ -128,6 +130,9 @@ func (Pipe) Run(ctx *context.Context) error {
 			}
 			artifacts := ctx.Artifacts.Filter(artifact.And(filters...))
 			log.WithField("artifacts", artifacts.Paths()).Debug("found artifacts")
+			if len(artifacts.Paths()) == 0 {
+				log.Warn("not binaries or packages found for the given platform - COPY/ADD may not work")
+			}
 			return process(ctx, docker, artifacts.List())
 		})
 	}


Test patch:
diff --git a/internal/pipe/checksums/checksums_test.go b/internal/pipe/checksums/checksums_test.go
index 6568672e..fde1baa0 100644
--- a/internal/pipe/checksums/checksums_test.go
+++ b/internal/pipe/checksums/checksums_test.go
@@ -344,6 +344,19 @@ func TestPipeCheckSumsWithExtraFiles(t *testing.T) {
 					require.Contains(t, string(bts), "3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  "+want)
 				}
 			}
+
+			_ = ctx.Artifacts.Visit(func(a *artifact.Artifact) error {
+				if a.Path != file {
+					return nil
+				}
+				if len(tt.ids) > 0 {
+					return nil
+				}
+				checkSum, err := artifact.Extra[string](*a, artifactChecksumExtra)
+				require.Nil(t, err)
+				require.NotEmptyf(t, checkSum, "failed: %v", a.Path)
+				return nil
+			})
 		})
 	}
 }