mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-19 19:10:18 +02:00
fix: skip publish on exec (#3800)
This commit is contained in:
parent
1aa984d006
commit
702164076d
@ -14,7 +14,6 @@ import (
|
|||||||
"github.com/goreleaser/goreleaser/internal/extrafiles"
|
"github.com/goreleaser/goreleaser/internal/extrafiles"
|
||||||
"github.com/goreleaser/goreleaser/internal/gio"
|
"github.com/goreleaser/goreleaser/internal/gio"
|
||||||
"github.com/goreleaser/goreleaser/internal/logext"
|
"github.com/goreleaser/goreleaser/internal/logext"
|
||||||
"github.com/goreleaser/goreleaser/internal/pipe"
|
|
||||||
"github.com/goreleaser/goreleaser/internal/semerrgroup"
|
"github.com/goreleaser/goreleaser/internal/semerrgroup"
|
||||||
"github.com/goreleaser/goreleaser/internal/tmpl"
|
"github.com/goreleaser/goreleaser/internal/tmpl"
|
||||||
"github.com/goreleaser/goreleaser/pkg/config"
|
"github.com/goreleaser/goreleaser/pkg/config"
|
||||||
@ -26,10 +25,6 @@ var passthroughEnvVars = []string{"HOME", "USER", "USERPROFILE", "TMPDIR", "TMP"
|
|||||||
|
|
||||||
// Execute the given publisher
|
// Execute the given publisher
|
||||||
func Execute(ctx *context.Context, publishers []config.Publisher) error {
|
func Execute(ctx *context.Context, publishers []config.Publisher) error {
|
||||||
if ctx.SkipPublish {
|
|
||||||
return pipe.ErrSkipPublishEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, p := range publishers {
|
for _, p := range publishers {
|
||||||
log.WithField("name", p.Name).Debug("executing custom publisher")
|
log.WithField("name", p.Name).Debug("executing custom publisher")
|
||||||
err := executePublisher(ctx, p)
|
err := executePublisher(ctx, p)
|
||||||
|
@ -10,8 +10,11 @@ import (
|
|||||||
type Pipe struct{}
|
type Pipe struct{}
|
||||||
|
|
||||||
// String returns the description of the pipe.
|
// String returns the description of the pipe.
|
||||||
func (Pipe) String() string { return "custom publisher" }
|
func (Pipe) String() string { return "custom publisher" }
|
||||||
func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Publishers) == 0 }
|
|
||||||
|
func (Pipe) Skip(ctx *context.Context) bool {
|
||||||
|
return len(ctx.Config.Publishers) == 0 || ctx.SkipPublish
|
||||||
|
}
|
||||||
|
|
||||||
// Publish artifacts.
|
// Publish artifacts.
|
||||||
func (Pipe) Publish(ctx *context.Context) error {
|
func (Pipe) Publish(ctx *context.Context) error {
|
||||||
|
@ -17,6 +17,16 @@ func TestSkip(t *testing.T) {
|
|||||||
require.True(t, Pipe{}.Skip(context.New(config.Project{})))
|
require.True(t, Pipe{}.Skip(context.New(config.Project{})))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("skip on skip-publish", func(t *testing.T) {
|
||||||
|
ctx := context.New(config.Project{
|
||||||
|
Publishers: []config.Publisher{
|
||||||
|
{},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
ctx.SkipPublish = true
|
||||||
|
require.True(t, Pipe{}.Skip(ctx))
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("dont skip", func(t *testing.T) {
|
t.Run("dont skip", func(t *testing.T) {
|
||||||
ctx := context.New(config.Project{
|
ctx := context.New(config.Project{
|
||||||
Publishers: []config.Publisher{
|
Publishers: []config.Publisher{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user