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