Repository: goreleaser/goreleaser
Pull request #3548 (2022-11-13 10:01:00)

feat: output checksums to artifacts info
Following #3540, output artifacts' checksums to the artifact info.
This addition makes it easier to consume the checksums, especially when running from e.g. GitHub Actions.

New tests:
1. Add a check for the checksum in the extra field. 
2. Add a test for every checksum algorithm (to see that it doesn't break for any algo's output).
3. Add a case of a binary and an extra file (to see that the logic doesn't break when there's a mix).

p.s.
While working on that, I noticed that the convention for extra fields is actually to use UpperCamelCase rather than lower. 
I was mistaken because I looked at the subfields of the "DockerConfig" extra field.
I think it's a good idea to fix it quickly, before the next release rolls and it becomes a compatibility issue.
I took the liberty to fix it here as an extra commit. Please let me know if you want it to be in a separate PR.

---
Tests:
```
go test
  • refreshing checksums                             file=binary_bar_checksums.txt
  • refreshing checksums                             file=binary_bar_checksums.txt
  • refreshing checksums                             file=binary_bar_checksums.txt
PASS
ok  	github.com/goreleaser/goreleaser/internal/pipe/checksums	0.184s
```

codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/3548?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) Report
> Merging [#3548](https://codecov.io/gh/goreleaser/goreleaser/pull/3548?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (614b935) into [main](https://codecov.io/gh/goreleaser/goreleaser/commit/e1ab1049ed836df65054c2690c4ca3daf88f610e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (e1ab104) will **decrease** coverage by `0.02%`.
> The diff coverage is `70.00%`.

```diff
@@            Coverage Diff             @@
##             main    #3548      +/-   ##
==========================================
- Coverage   83.64%   83.61%   -0.03%     
==========================================
  Files         116      116              
  Lines        9692     9712      +20     
==========================================
+ Hits         8107     8121      +14     
- Misses       1284     1288       +4     
- Partials      301      303       +2     
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/3548?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) | Coverage Δ | |
|---|---|---|
| [internal/pipe/docker/docker.go](https://codecov.io/gh/goreleaser/goreleaser/pull/3548/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-aW50ZXJuYWwvcGlwZS9kb2NrZXIvZG9ja2VyLmdv) | `91.32% <ø> (ø)` | |
| [internal/pipe/checksums/checksums.go](https://codecov.io/gh/goreleaser/goreleaser/pull/3548/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-aW50ZXJuYWwvcGlwZS9jaGVja3N1bXMvY2hlY2tzdW1zLmdv) | `94.87% <70.00%> (-5.13%)` | :arrow_down: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)


Patch:
diff --git a/.github/workflows/depsreview.yaml b/.github/workflows/depsreview.yaml
index 9186edae..68fb1d17 100644
--- a/.github/workflows/depsreview.yaml
+++ b/.github/workflows/depsreview.yaml
@@ -9,6 +9,6 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3
-      - uses: actions/dependency-review-action@v2
+      - uses: actions/dependency-review-action@v3
         with:
           allow-licenses: BSD-2-Clause, BSD-3-Clause, MIT, Apache-2.0, MPL-2.0
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 21963c85..3ab01aa4 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -22,7 +22,7 @@ jobs:
           go-version: '>=1.19.3'
       - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3
       - name: golangci-lint
-        uses: golangci/golangci-lint-action@07db5389c99593f11ad7b44463c2d4233066a9b1 # v3
+        uses: golangci/golangci-lint-action@0ad9a0988b3973e851ab0a07adf248ec2e100376 # v3
         with:
           skip-go-installation: true
           args: --timeout=5m
diff --git a/USERS.md b/USERS.md
index 9d9119f9..2bfeb2f7 100644
--- a/USERS.md
+++ b/USERS.md
@@ -30,6 +30,7 @@ Here's a running list of some organizations using GoReleaser[^1]:
 1. [IRON Security](https://iron.security)
 1. [Koordinator](https://koordinator.sh)
 1. [KSOC](https://www.ksoc.com/)
+1. [Mercure](https://mercure.rocks/)
 1. [Meroxa](https://meroxa.com/)
 1. [Microsoft](https://microsoft.com)
 1. [Minio](https://min.io)
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 7f868af3..82ca2ce2 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"
@@ -47,6 +47,9 @@ func (Pipe) Default(ctx *context.Context) error {
 		if docker.Goarch == "" {
 			docker.Goarch = "amd64"
 		}
+		if docker.Goarm == "" {
+			docker.Goarm = "6"
+		}
 		if docker.Goamd64 == "" {
 			docker.Goamd64 = "v1"
 		}
diff --git a/www/docs/customization/docker.md b/www/docs/customization/docker.md
index 35e19975..038c8fcf 100644
--- a/www/docs/customization/docker.md
+++ b/www/docs/customization/docker.md
@@ -50,18 +50,23 @@ dockers:
     id: myimg
 
     # GOOS of the built binaries/packages that should be used.
+    # Default: `linux`.
     goos: linux
 
     # GOARCH of the built binaries/packages that should be used.
+    # Default: `amd64`.
     goarch: amd64
 
     # GOARM of the built binaries/packages that should be used.
+    # Default: `6`.
     goarm: ''
 
     # GOAMD64 of the built binaries/packages that should be used.
+    # Default: `v1`.
     goamd64: 'v2'
 
     # IDs to filter the binaries/packages.
+    # Default: `empty`.
     ids:
     - mybuild
     - mynfpm
diff --git a/www/docs/users.md b/www/docs/users.md
index 9d9119f9..2bfeb2f7 100644
--- a/www/docs/users.md
+++ b/www/docs/users.md
@@ -30,6 +30,7 @@ Here's a running list of some organizations using GoReleaser[^1]:
 1. [IRON Security](https://iron.security)
 1. [Koordinator](https://koordinator.sh)
 1. [KSOC](https://www.ksoc.com/)
+1. [Mercure](https://mercure.rocks/)
 1. [Meroxa](https://meroxa.com/)
 1. [Microsoft](https://microsoft.com)
 1. [Minio](https://min.io)


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
+			})
 		})
 	}
 }
diff --git a/internal/pipe/defaults/defaults_test.go b/internal/pipe/defaults/defaults_test.go
index 5e8e9079..d1b3191a 100644
--- a/internal/pipe/defaults/defaults_test.go
+++ b/internal/pipe/defaults/defaults_test.go
@@ -92,8 +92,9 @@ func TestFillPartial(t *testing.T) {
 	require.Len(t, ctx.Config.Archives[0].Files, 1)
 	require.NotEmpty(t, ctx.Config.Dockers[0].Goos)
 	require.NotEmpty(t, ctx.Config.Dockers[0].Goarch)
+	require.NotEmpty(t, ctx.Config.Dockers[0].Goarm)
+	require.NotEmpty(t, ctx.Config.Dockers[0].Goamd64)
 	require.NotEmpty(t, ctx.Config.Dockers[0].Dockerfile)
-	require.Empty(t, ctx.Config.Dockers[0].Goarm)
 	require.Equal(t, "disttt", ctx.Config.Dist)
 	require.NotEqual(t, "https://github.com", ctx.Config.GitHubURLs.Download)
 
diff --git a/internal/pipe/docker/docker_test.go b/internal/pipe/docker/docker_test.go
index 56115f5d..712f388f 100644
--- a/internal/pipe/docker/docker_test.go
+++ b/internal/pipe/docker/docker_test.go
@@ -1182,6 +1182,7 @@ func TestDefault(t *testing.T) {
 	docker := ctx.Config.Dockers[0]
 	require.Equal(t, "linux", docker.Goos)
 	require.Equal(t, "amd64", docker.Goarch)
+	require.Equal(t, "6", docker.Goarm)
 	require.Equal(t, []string{"aa"}, docker.IDs)
 	require.Equal(t, useDocker, docker.Use)
 	docker = ctx.Config.Dockers[1]