Repository: goreleaser/goreleaser
Pull request #2982 (2022-03-17 00:39:36)

feat: deprecate buildpacks
closes https://github.com/goreleaser/goreleaser/issues/2976

codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2982?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) Report
> Merging [#2982](https://codecov.io/gh/goreleaser/goreleaser/pull/2982?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (438905f) into [main](https://codecov.io/gh/goreleaser/goreleaser/commit/3eaec333d7f4ade0f92f2e51b00124ba3660a6f1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (3eaec33) will **decrease** coverage by `0.02%`.
> The diff coverage is `0.00%`.

```diff
@@            Coverage Diff             @@
##             main    #2982      +/-   ##
==========================================
- Coverage   84.48%   84.45%   -0.03%     
==========================================
  Files         111      111              
  Lines        9010     9013       +3     
==========================================
  Hits         7612     7612              
- Misses       1124     1126       +2     
- Partials      274      275       +1     
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/2982?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) | Coverage Δ | |
|---|---|---|
| [internal/pipe/docker/api\_buildpack.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2982/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-aW50ZXJuYWwvcGlwZS9kb2NrZXIvYXBpX2J1aWxkcGFjay5nbw==) | `85.71% <ø> (ø)` | |
| [internal/pipe/docker/docker.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2982/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-aW50ZXJuYWwvcGlwZS9kb2NrZXIvZG9ja2VyLmdv) | `87.56% <0.00%> (-1.45%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2982?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/2982?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Last update [3eaec33...438905f](https://codecov.io/gh/goreleaser/goreleaser/pull/2982?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: 
> There is one linting issue!

Golangci lint is not working in go 1.18 yet 🥲

Patch:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 57e2ad89..75ac900c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -55,11 +55,6 @@ jobs:
           repo-token: ${{ secrets.GITHUB_TOKEN }}
       - uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # v1
       - uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 # v1
-      - name: setup-buildpacks
-        run: |
-          sudo add-apt-repository ppa:cncf-buildpacks/pack-cli
-          sudo apt-get update
-          sudo apt-get --no-install-suggests --no-install-recommends install pack-cli
       - name: setup-snapcraft
         # FIXME: the mkdirs are a hack for https://github.com/goreleaser/goreleaser/issues/1715
         run: |
diff --git a/internal/deprecate/deprecate.go b/internal/deprecate/deprecate.go
index 5f5b815a..fd961ffc 100644
--- a/internal/deprecate/deprecate.go
+++ b/internal/deprecate/deprecate.go
@@ -55,6 +55,8 @@ func NoticeCustom(ctx *context.Context, property, tmpl string) {
 	url := baseURL + strings.NewReplacer(
 		".", "",
 		"_", "",
+		":", "",
+		" ", "-",
 	).Replace(property)
 	var out bytes.Buffer
 	if err := template.Must(template.New("deprecation").Parse("DEPRECATED: "+tmpl)).Execute(&out, templateData{
diff --git a/internal/pipe/docker/api_buildpack.go b/internal/pipe/docker/api_buildpack.go
index de862b68..e77425ac 100644
--- a/internal/pipe/docker/api_buildpack.go
+++ b/internal/pipe/docker/api_buildpack.go
@@ -7,6 +7,7 @@ import (
 	"github.com/goreleaser/goreleaser/pkg/context"
 )
 
+// deprected: should not be used anymore.
 type buildPackImager struct{}
 
 func (i buildPackImager) Push(ctx *context.Context, image string, flags []string) error {
diff --git a/internal/pipe/docker/docker.go b/internal/pipe/docker/docker.go
index 1dd1e86d..6d865556 100644
--- a/internal/pipe/docker/docker.go
+++ b/internal/pipe/docker/docker.go
@@ -9,6 +9,7 @@ import (
 
 	"github.com/apex/log"
 	"github.com/goreleaser/goreleaser/internal/artifact"
+	"github.com/goreleaser/goreleaser/internal/deprecate"
 	"github.com/goreleaser/goreleaser/internal/gio"
 	"github.com/goreleaser/goreleaser/internal/ids"
 	"github.com/goreleaser/goreleaser/internal/pipe"
@@ -23,7 +24,7 @@ const (
 
 	useBuildx     = "buildx"
 	useDocker     = "docker"
-	useBuildPacks = "buildpacks"
+	useBuildPacks = "buildpacks" // deprecated: should not be used anymore
 )
 
 // Pipe for docker.
@@ -50,6 +51,9 @@ func (Pipe) Default(ctx *context.Context) error {
 		if docker.Dockerfile == "" {
 			docker.Dockerfile = "Dockerfile"
 		}
+		if docker.Use == useBuildPacks {
+			deprecate.Notice(ctx, "dockers.use: buildpacks")
+		}
 		if docker.Use == "" {
 			docker.Use = useDocker
 		}
diff --git a/www/docs/customization/docker.md b/www/docs/customization/docker.md
index 2969ed1c..0babcb1c 100644
--- a/www/docs/customization/docker.md
+++ b/www/docs/customization/docker.md
@@ -86,7 +86,7 @@ dockers:
     dockerfile: '{{ .Env.DOCKERFILE }}'
 
     # Set the "backend" for the Docker pipe.
-    # Valid options are: docker, buildx, podman, buildpacks
+    # Valid options are: docker, buildx, podman.
     # podman is a GoReleaser Pro feature and is only available on Linux.
     # Defaults to docker.
     use: docker
@@ -255,29 +255,3 @@ dockers:
 
 Note that GoReleaser will not install Podman for you, nor change any of its configuration.
 
-## Buildpacks
-
-You can use [`buildpacks`](https://buildpacks.io) instead of `docker` by setting `use` to `buildpacks` on your config:
-
-```yaml
-# .goreleaser.yaml
-dockers:
-  -
-    image_templates:
-    - "myuser/myimage"
-    use: buildpacks
-```
-
-Also, you can use a custom buildpack on `build_flag_templates` if you want.
-By default, `gcr.io/buildpacks/builder:v1` will be used.
-
-```yaml
-# .goreleaser.yaml
-dockers:
-  -
-    image_templates:
-    - "myuser/myimage"
-    use: buildpacks
-    build_flag_templates:
-    - "--builder=heroku/buildpacks:20"
-```
diff --git a/www/docs/deprecations.md b/www/docs/deprecations.md
index 82dbdf0c..99db00aa 100644
--- a/www/docs/deprecations.md
+++ b/www/docs/deprecations.md
@@ -36,6 +36,15 @@ Description.
 
 -->
 
+### dockers.use: buildpacks
+
+> since 2022-03-16 (v1.6.0)
+
+This will be removed soon due to some issues:
+
+- The binary gets rebuild again during the buildpacks build;
+- There is no ARM support.
+
 ### variables
 
 > since 2022-01-20 (v1.4.0)
@@ -107,7 +116,6 @@ ignore:
 
 If you try to use new versions of GoReleaser with Go 1.16 or older, it will warn about it until this deprecation warning expires, after that your build will likely fail.
 
-
 ## Expired deprecation notices
 
 The following options were deprecated in the past and were already removed.


Test patch:
diff --git a/internal/deprecate/deprecate_test.go b/internal/deprecate/deprecate_test.go
index 727ae54c..35a7cb58 100644
--- a/internal/deprecate/deprecate_test.go
+++ b/internal/deprecate/deprecate_test.go
@@ -21,7 +21,7 @@ func TestNotice(t *testing.T) {
 
 	log.Info("first")
 	ctx := context.New(config.Project{})
-	Notice(ctx, "foo.bar.whatever")
+	Notice(ctx, "foo.bar.whatever: foobar")
 	log.Info("last")
 	require.True(t, ctx.Deprecated)
 
diff --git a/internal/deprecate/testdata/TestNotice.txt.golden b/internal/deprecate/testdata/TestNotice.txt.golden
index 7048f686..efd3e0f7 100644
--- a/internal/deprecate/testdata/TestNotice.txt.golden
+++ b/internal/deprecate/testdata/TestNotice.txt.golden
@@ -1,3 +1,3 @@
    • first                    
-      • DEPRECATED: `foo.bar.whatever` should not be used anymore, check https://goreleaser.com/deprecations#foobarwhatever for more info
+      • DEPRECATED: `foo.bar.whatever: foobar` should not be used anymore, check https://goreleaser.com/deprecations#foobarwhatever-foobar for more info
    • last                     
diff --git a/internal/pipe/docker/api_buildpack_test.go b/internal/pipe/docker/api_buildpack_test.go
deleted file mode 100644
index b1d5b352..00000000
--- a/internal/pipe/docker/api_buildpack_test.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package docker
-
-import (
-	"testing"
-
-	"github.com/stretchr/testify/require"
-)
-
-func TestBuildCommandForBuildPack(t *testing.T) {
-	images := []string{"goreleaser/test_build_flag", "goreleaser/test_multiple_tags"}
-	tests := []struct {
-		name   string
-		flags  []string
-		expect []string
-	}{
-		{
-			name:   "no flags without builder",
-			flags:  []string{},
-			expect: []string{"build", images[0], "-t", images[1], "--builder=gcr.io/buildpacks/builder:v1"},
-		},
-		{
-			name:   "single flag without builder",
-			flags:  []string{"--clear-cache"},
-			expect: []string{"build", images[0], "-t", images[1], "--clear-cache", "--builder=gcr.io/buildpacks/builder:v1"},
-		},
-		{
-			name:   "multiple flags without builder",
-			flags:  []string{"--clear-cache", "--verbose"},
-			expect: []string{"build", images[0], "-t", images[1], "--clear-cache", "--verbose", "--builder=gcr.io/buildpacks/builder:v1"},
-		},
-		{
-			name:   "builder with --builder flag",
-			flags:  []string{"--builder=heroku/buildpacks:20"},
-			expect: []string{"build", images[0], "-t", images[1], "--builder=heroku/buildpacks:20"},
-		},
-		{
-			name:   "builder with -B flag",
-			flags:  []string{"-B=heroku/buildpacks:18"},
-			expect: []string{"build", images[0], "-t", images[1], "-B=heroku/buildpacks:18"},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			imager := buildPackImager{}
-			require.Equal(t, tt.expect, imager.buildCommand(images, tt.flags))
-		})
-	}
-}
diff --git a/internal/pipe/docker/docker_test.go b/internal/pipe/docker/docker_test.go
index 24d57f86..d1e4b561 100644
--- a/internal/pipe/docker/docker_test.go
+++ b/internal/pipe/docker/docker_test.go
@@ -972,8 +972,8 @@ func TestRunPipe(t *testing.T) {
 
 	for name, docker := range table {
 		for imager := range imagers {
-			if imager == useBuildPacks { // buildpack tests are different
-				continue
+			if imager == useBuildPacks {
+				continue // deprecated
 			}
 			t.Run(name+" on "+imager, func(t *testing.T) {
 				folder := t.TempDir()
@@ -1089,92 +1089,6 @@ func TestRunPipe(t *testing.T) {
 	}
 }
 
-func TestRunPipeWhileUsingBuildpacks(t *testing.T) {
-	testlib.CheckPath(t, "pack")
-	type errChecker func(*testing.T, error)
-	shouldNotErr := func(t *testing.T, err error) {
-		t.Helper()
-		require.NoError(t, err)
-	}
-
-	table := map[string]struct {
-		dockers             []config.Docker
-		manifests           []config.DockerManifest
-		expect              []string
-		assertError         errChecker
-		pubAssertError      errChecker
-		manifestAssertError errChecker
-	}{
-		"golang": {
-			dockers: []config.Docker{
-				{
-					Use:            useBuildPacks,
-					ImageTemplates: []string{registry + "goreleaser/buildpacks:{{ .Tag }}"},
-				},
-			},
-			expect: []string{
-				registry + "goreleaser/buildpacks:v1.0.0",
-			},
-			assertError:         shouldNotErr,
-			pubAssertError:      shouldNotErr,
-			manifestAssertError: shouldNotErr,
-		},
-	}
-
-	killAndRm(t)
-	start(t)
-	defer killAndRm(t)
-
-	for name, docker := range table {
-		t.Run(name+" on "+useBuildPacks, func(t *testing.T) {
-			folder := t.TempDir()
-			wd := filepath.Join(folder, "wd")
-			dist := filepath.Join(wd, "dist")
-			require.NoError(t, os.Mkdir(wd, 0o755))
-			require.NoError(t, os.Mkdir(dist, 0o755))
-			require.NoError(t, os.Chdir(wd))
-			require.NoError(t, os.WriteFile(filepath.Join(wd, "go.mod"), []byte("module test-mod\n\ngo 1.18"), 0o600))
-			require.NoError(t, os.WriteFile(filepath.Join(wd, "main.go"), []byte("package main\n\nfunc main(){}"), 0o600))
-
-			ctx := context.New(config.Project{
-				ProjectName: "mybin",
-				Dist:        dist,
-				Dockers:     docker.dockers,
-			})
-
-			ctx.Parallelism = 1
-			ctx.Version = "1.0.0"
-			ctx.Git = context.GitInfo{
-				CurrentTag: "v1.0.0",
-				Commit:     "a1b2c3d4",
-			}
-			ctx.Semver = context.Semver{
-				Major: 1,
-				Minor: 0,
-				Patch: 0,
-			}
-
-			rmi := func(img string) error {
-				return exec.Command("docker", "rmi", "--force", img).Run()
-			}
-
-			err := Pipe{}.Run(ctx)
-			docker.assertError(t, err)
-			if err == nil {
-				docker.pubAssertError(t, Pipe{}.Publish(ctx))
-				docker.manifestAssertError(t, ManifestPipe{}.Publish(ctx))
-			}
-
-			// this might should not fail as the image should have been created when
-			// the step ran
-			for _, img := range docker.expect {
-				t.Log("removing docker image", img)
-				require.NoError(t, rmi(img), "could not delete image %s", img)
-			}
-		})
-	}
-}
-
 func TestBuildCommand(t *testing.T) {
 	images := []string{"goreleaser/test_build_flag", "goreleaser/test_multiple_tags"}
 	tests := []struct {