mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-13 11:50:34 +02:00
parent
3d110afc77
commit
9081caba5e
@ -188,10 +188,18 @@ func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifac
|
||||
if err := dockerBuild(ctx, tmp, images, buildFlags); err != nil {
|
||||
return err
|
||||
}
|
||||
if docker.SkipPush {
|
||||
// TODO: this should also be better handled
|
||||
log.Warn(pipe.Skip("skip_push is set").Error())
|
||||
return nil
|
||||
|
||||
if strings.TrimSpace(docker.SkipPush) == "true" {
|
||||
return pipe.Skip("docker.skip_push is set")
|
||||
}
|
||||
if ctx.SkipPublish {
|
||||
return pipe.ErrSkipPublishEnabled
|
||||
}
|
||||
if ctx.Config.Release.Draft {
|
||||
return pipe.Skip("release is marked as draft")
|
||||
}
|
||||
if strings.TrimSpace(docker.SkipPush) == "auto" && ctx.Semver.Prerelease != "" {
|
||||
return pipe.Skip("prerelease detected with 'auto' push, skipping docker publish")
|
||||
}
|
||||
for _, img := range images {
|
||||
ctx.Artifacts.Add(artifact.Artifact{
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe"
|
||||
"github.com/goreleaser/goreleaser/internal/testlib"
|
||||
"github.com/goreleaser/goreleaser/pkg/config"
|
||||
"github.com/goreleaser/goreleaser/pkg/context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -223,15 +224,14 @@ func TestRunPipe(t *testing.T) {
|
||||
Goarch: "amd64",
|
||||
Dockerfile: "testdata/Dockerfile",
|
||||
Binaries: []string{"mybin"},
|
||||
SkipPush: true,
|
||||
SkipPush: "true",
|
||||
},
|
||||
},
|
||||
expect: []string{
|
||||
registry + "goreleaser/test_run_pipe:latest",
|
||||
},
|
||||
assertImageLabels: noLabels,
|
||||
assertError: shouldNotErr,
|
||||
pubAssertError: shouldNotErr,
|
||||
assertError: testlib.AssertSkipped,
|
||||
},
|
||||
"valid_no_latest": {
|
||||
dockers: []config.Docker{
|
||||
@ -384,7 +384,7 @@ func TestRunPipe(t *testing.T) {
|
||||
Goarch: "amd64",
|
||||
Dockerfile: "testdata/Dockerfile",
|
||||
Binaries: []string{"mybin"},
|
||||
SkipPush: true,
|
||||
SkipPush: "true",
|
||||
},
|
||||
},
|
||||
env: map[string]string{
|
||||
@ -395,8 +395,7 @@ func TestRunPipe(t *testing.T) {
|
||||
registry + "goreleaser/mybin:latest",
|
||||
},
|
||||
assertImageLabels: noLabels,
|
||||
assertError: shouldNotErr,
|
||||
pubAssertError: shouldNotErr,
|
||||
assertError: testlib.AssertSkipped,
|
||||
},
|
||||
"no_permissions": {
|
||||
dockers: []config.Docker{
|
||||
@ -768,7 +767,7 @@ func Test_processImageTemplates(t *testing.T) {
|
||||
"gcr.io/image:{{.Tag}}-{{.Env.FOO}}",
|
||||
"gcr.io/image:v{{.Major}}.{{.Minor}}",
|
||||
},
|
||||
SkipPush: true,
|
||||
SkipPush: "true",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -23,7 +23,7 @@ func TestPublish(t *testing.T) {
|
||||
var ctx = context.New(config.Project{})
|
||||
ctx.Config.Release.Disable = true
|
||||
for i := range ctx.Config.Dockers {
|
||||
ctx.Config.Dockers[i].SkipPush = true
|
||||
ctx.Config.Dockers[i].SkipPush = "true"
|
||||
}
|
||||
require.NoError(t, Pipe{}.Run(ctx))
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ type Docker struct {
|
||||
Image string `yaml:",omitempty"`
|
||||
Dockerfile string `yaml:",omitempty"`
|
||||
ImageTemplates []string `yaml:"image_templates,omitempty"`
|
||||
SkipPush bool `yaml:"skip_push,omitempty"`
|
||||
SkipPush string `yaml:"skip_push,omitempty"`
|
||||
TagTemplates []string `yaml:"tag_templates,omitempty"`
|
||||
Files []string `yaml:"extra_files,omitempty"`
|
||||
BuildFlagTemplates []string `yaml:"build_flag_templates,omitempty"`
|
||||
|
@ -65,6 +65,8 @@ dockers:
|
||||
- "myuser/myimage:v{{ .Major }}"
|
||||
- "gcr.io/myuser/myimage:latest"
|
||||
# Skips the docker push. Could be useful if you also do draft releases.
|
||||
# If set to auto, the release will not be pushed to the docker repository
|
||||
# in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
|
||||
# Defaults to false.
|
||||
skip_push: false
|
||||
# Path to the Dockerfile (from the project root).
|
||||
|
Loading…
x
Reference in New Issue
Block a user