mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-11 11:42:15 +02:00
feat: deprecate buildpacks (#2982)
This commit is contained in:
parent
31df0a0716
commit
0a66b3dc85
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@ -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: |
|
||||
|
@ -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{
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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))
|
||||
})
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
```
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user