Repository: goreleaser/goreleaser
Pull request #2779 (2021-12-21 12:23:59)

feat: do not release goreleaser for arm6
has virtually no downloads, and was never really tested...

I think we can have fewer targets, only the most common ones. Should speed up the release a bit and also lower the number of files in the release


wdyt?

codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2779?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) Report
> Merging [#2779](https://codecov.io/gh/goreleaser/goreleaser/pull/2779?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (eb52fd9) into [main](https://codecov.io/gh/goreleaser/goreleaser/commit/559d3ad4e7da1d92098d3ab8ac67ac107f86a6e9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (559d3ad) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/2779/graphs/tree.svg?width=650&height=150&src=pr&token=3bJvv6b7hN&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)](https://codecov.io/gh/goreleaser/goreleaser/pull/2779?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)

```diff
@@           Coverage Diff           @@
##             main    #2779   +/-   ##
=======================================
  Coverage   84.94%   84.94%           
=======================================
  Files         106      106           
  Lines        8235     8235           
=======================================
  Hits         6995     6995           
  Misses       1010     1010           
  Partials      230      230           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2779?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2779?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Last update [559d3ad...eb52fd9](https://codecov.io/gh/goreleaser/goreleaser/pull/2779?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).

caarlos0: problem is that both armv6 and armv7 are "armhf" on debian, so the filenames colide as well... and since its EOL soon and is not downloaded most of time, IMHO, we can remove it now...

Patch:
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index 49381a8d..0027a36f 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -25,7 +25,6 @@ builds:
     - arm
     - arm64
   goarm:
-    - "6"
     - "7"
   mod_timestamp: '{{ .CommitTimestamp }}'
   flags:
@@ -133,6 +132,7 @@ brews:
       owner: goreleaser
       name: homebrew-tap
     folder: Formula
+    goarm: "7"
     homepage:  https://goreleaser.com
     description: Deliver Go binaries as fast and easily as possible
     license: MIT
diff --git a/Taskfile.yml b/Taskfile.yml
index 8c97cef6..3b43d6a3 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -150,11 +150,6 @@ tasks:
           Platform: 'arm64'
           Image: fedora
           Cmd: '{{.rpm}} goreleaser-*.aarch64.rpm'
-      - task: goreleaser:test:pkg
-        vars:
-          Platform: 'arm/6'
-          Image: fedora
-          Cmd: '{{.rpm}} goreleaser-*.armv6hl.rpm'
       - task: goreleaser:test:pkg
         vars:
           Platform: 'arm/7'
@@ -176,11 +171,6 @@ tasks:
           Platform: 'arm64'
           Image: ubuntu
           Cmd: '{{.dpkg}} goreleaser*_arm64.deb'
-      - task: goreleaser:test:pkg
-        vars:
-          Platform: 'arm/6'
-          Image: debian
-          Cmd: '{{.dpkg}} goreleaser*_armel.deb'
       - task: goreleaser:test:pkg
         vars:
           Platform: 'arm/7'
@@ -207,11 +197,6 @@ tasks:
           Platform: 'arm64'
           Image: alpine
           Cmd: '{{.apk}} goreleaser*_aarch64.apk'
-      - task: goreleaser:test:pkg
-        vars:
-          Platform: 'arm/6'
-          Image: alpine
-          Cmd: '{{.apk}} goreleaser*_armhf.apk'
       - task: goreleaser:test:pkg
         vars:
           Platform: 'arm/7'
diff --git a/internal/pipe/changelog/changelog.go b/internal/pipe/changelog/changelog.go
index ca0d7f28..f7d37d16 100644
--- a/internal/pipe/changelog/changelog.go
+++ b/internal/pipe/changelog/changelog.go
@@ -14,6 +14,7 @@ import (
 	"github.com/goreleaser/goreleaser/internal/client"
 	"github.com/goreleaser/goreleaser/internal/git"
 	"github.com/goreleaser/goreleaser/internal/tmpl"
+	"github.com/goreleaser/goreleaser/pkg/config"
 	"github.com/goreleaser/goreleaser/pkg/context"
 )
 
@@ -71,7 +72,7 @@ func (Pipe) Run(ctx *context.Context) error {
 		"## Changelog",
 	}
 
-	if len(ctx.Config.Changelog.Groups) > 0 {
+	if shouldGroup(ctx.Config.Changelog) {
 		log.Debug("grouping entries")
 		groups := ctx.Config.Changelog.Groups
 
@@ -124,6 +125,10 @@ func (Pipe) Run(ctx *context.Context) error {
 	return os.WriteFile(path, []byte(ctx.ReleaseNotes), 0o644) //nolint: gosec
 }
 
+func shouldGroup(cfg config.Changelog) bool {
+	return len(cfg.Groups) > 0 && cfg.Use != "github-native"
+}
+
 func getAllNonEmpty(ss []string) []string {
 	var r []string
 	for _, s := range ss {
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 9c1bc06e..7b19ff63 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -744,7 +744,7 @@ type Changelog struct {
 	Filters Filters          `yaml:"filters,omitempty"`
 	Sort    string           `yaml:"sort,omitempty"`
 	Skip    bool             `yaml:"skip,omitempty"` // TODO(caarlos0): rename to Disable to match other pipes
-	Use     string           `yaml:"use,omitempty"`
+	Use     string           `yaml:"use,omitempty" jsonschema:"enum=git,enum=github,enum=github-native,enum=gitlab,default=git"`
 	Groups  []ChangeLogGroup `yaml:"groups,omitempty"`
 }
 
diff --git a/www/docs/cookbooks/override-image-name.md b/www/docs/cookbooks/override-image-name.md
new file mode 100644
index 00000000..9cb3c925
--- /dev/null
+++ b/www/docs/cookbooks/override-image-name.md
@@ -0,0 +1,48 @@
+# Override hardcoded registry and image name ?
+
+If you are curious about how to avoid hard-coded registry and image names within your `.goreleaser.yml`, we have good news for you. Here is the solution. Suppose you haven't been aware of GoReleaser Action, which allows you to install GoReleaser binary in your workflow easily. In that case, this is the right time to be mindful of that because, in this section, we'll give an example through GoReleaser's GitHub Action.
+
+> To get more detail about the GoReleaser's GitHub Action, please [see](https://github.com/goreleaser/goreleaser-action).
+
+As you can see from the description [here](https://github.com/goreleaser/goreleaser-action#environment-variables), you can pass environment variables to the GoReleaser to use within the `.goreleaser.yml` via syntax `{{ .Env.<something> }}`. So, let' define our registry and image names as an [environment variable in the workflow](https://docs.github.com/en/actions/learn-github-actions/environment-variables), then pass those to the GoReleaser via `env` section of the GoReleaser's GitHub Action like the following:
+
+```YAML
+ jobs:
+  # use goreleaser to cross-compile go binaries and add them to GitHub release
+  goreleaser:
+    runs-on: ubuntu-latest
+    env:
+      REGISTRY: "ghcr.io"
+      IMAGE_NAME: "google/addlicense"
+...
+      - name: Run GoReleaser
+        uses:  goreleaser/goreleaser-action@v2
+        with:
+          distribution: goreleaser
+          version: latest
+          args: release --rm-dist
+       env:
+         REGISTRY: ${{ env.REGISTRY }}
+         IMAGE: ${{ env.IMAGE_NAME }}
+         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+```
+
+Once you pass those to the GoReleaser, you can access them within your `.goreleaser.yml` file as I mentioned above, here is the example of this:
+
+```YAML
+dockers:
+    - image_templates:
+        - '{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Tag }}-amd64'
+      dockerfile: Dockerfile.goreleaser
+      use: buildx
+      build_flag_templates:
+        - "--pull"
+        - "--label=org.opencontainers.image.created={{.Date}}"
+        - "--label=org.opencontainers.image.name={{.ProjectName}}"
+        - "--label=org.opencontainers.image.revision={{.FullCommit}}"
+        - "--label=org.opencontainers.image.version={{.Version}}"
+        - "--label=org.opencontainers.image.source={{.GitURL}}"
+        - "--platform=linux/amd64"
+```
+
+That's all we need to do, you even might be surprised when you notice that how easy it is to overcome this issue.
diff --git a/www/docs/customization/changelog.md b/www/docs/customization/changelog.md
index 8417828b..468d1d65 100644
--- a/www/docs/customization/changelog.md
+++ b/www/docs/customization/changelog.md
@@ -15,7 +15,7 @@ changelog:
   # - `git`: uses `git log`;
   # - `github`: uses the compare GitHub API, appending the author login to the changelog.
   # - `gitlab`: uses the compare GitLab API, appending the author name and email to the changelog.
-  # - `github-native`: uses the GitHub release notes generation API.
+  # - `github-native`: uses the GitHub release notes generation API, disables the groups feature.
   #
   # Defaults to `git`.
   use: github
@@ -28,6 +28,8 @@ changelog:
   # Group commits messages by given regex and title.
   # Order value defines the order of the groups.
   # Proving no regex means all commits will be grouped under the default group.
+  # Groups are disabled when using github-native, as it already groups things by itself.
+  #
   # Default is no groups.
   groups:
     - title: Features
diff --git a/www/docs/customization/templates.md b/www/docs/customization/templates.md
index 1c5eac65..f317158a 100644
--- a/www/docs/customization/templates.md
+++ b/www/docs/customization/templates.md
@@ -80,7 +80,9 @@ On the nFPM name template field, you can use those extra fields as well:
 | `.Release`     | release from the nfpm config                               |
 | `.Epoch`       | epoch from the nfpm config                                 |
 | `.PackageName` | package the name. Same as `ProjectName` if not overridden. |
-| `.ConventionalFileName` | conventional package file name as provided by nFPM |
+| `.ConventionalFileName` | conventional package file name as provided by nFPM[^9] |
+
+[^9]: Please beware: some OSs might have the same names for different ARM versions, for example, for Debian both ARMv6 and ARMv7 are called `armhf`. Make sure that's not your case otherwise you might end up with colliding names.
 
 ## Functions
 
diff --git a/www/mkdocs.yml b/www/mkdocs.yml
index 478724dc..d406a6da 100644
--- a/www/mkdocs.yml
+++ b/www/mkdocs.yml
@@ -148,6 +148,7 @@ nav:
   - cookbooks/semantic-release.md
   - cookbooks/set-a-custom-git-tag.md
   - cookbooks/using-main.version.md
+  - cookbooks/override-image-name.md
 - Community:
   - sponsors.md
   - users.md


Test patch:
diff --git a/internal/pipe/changelog/changelog_test.go b/internal/pipe/changelog/changelog_test.go
index 28eefd5a..fd9c91f0 100644
--- a/internal/pipe/changelog/changelog_test.go
+++ b/internal/pipe/changelog/changelog_test.go
@@ -616,3 +616,32 @@ func TestGroupBadRegex(t *testing.T) {
 	ctx.Git.CurrentTag = "v0.0.2"
 	require.EqualError(t, Pipe{}.Run(ctx), `failed to group into "Something": error parsing regexp: missing closing ]: `+"`"+`[(\w`+"`")
 }
+
+func TestShouldGroup(t *testing.T) {
+	t.Run("with groups", func(t *testing.T) {
+		t.Run("github-native", func(t *testing.T) {
+			require.False(t, shouldGroup(config.Changelog{
+				Use:    "github-native",
+				Groups: []config.ChangeLogGroup{{}},
+			}))
+		})
+		for _, u := range []string{"git", "github", "gitlab"} {
+			t.Run(u, func(t *testing.T) {
+				require.True(t, shouldGroup(config.Changelog{
+					Use:    u,
+					Groups: []config.ChangeLogGroup{{}},
+				}))
+			})
+		}
+	})
+
+	t.Run("without groups", func(t *testing.T) {
+		for _, u := range []string{"git", "github", "gitlab", "github-native"} {
+			t.Run(u, func(t *testing.T) {
+				require.False(t, shouldGroup(config.Changelog{
+					Use: u,
+				}))
+			})
+		}
+	})
+}