1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-29 01:44:39 +02:00

fix: publish skip handling

This commit is contained in:
Carlos Alexandro Becker 2018-10-12 00:26:54 -03:00 committed by Carlos Alexandro Becker
parent c449328428
commit 23eb2c7756
3 changed files with 22 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/apex/log"
"github.com/fatih/color"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/pipe/brew"
"github.com/goreleaser/goreleaser/internal/pipe/scoop"
@ -32,16 +33,31 @@ var publishers = []Publisher{
scoop.Pipe{},
}
var bold = color.New(color.Bold)
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
if ctx.SkipPublish {
return pipe.ErrSkipPublishEnabled
}
for _, publisher := range publishers {
log.Infof("Publishing %s...", publisher.String())
if err := publisher.Publish(ctx); err != nil {
log.Infof(bold.Sprint(publisher.String()))
if err := handle(publisher.Publish(ctx)); err != nil {
return errors.Wrapf(err, "%s: failed to publish artifacts", publisher.String())
}
}
return nil
}
// TODO: for now this is duplicated, we should have better error handling
// eventually.
func handle(err error) error {
if err == nil {
return nil
}
if pipe.IsSkip(err) {
log.WithField("reason", err.Error()).Warn("skipped")
return nil
}
return err
}

View File

@ -21,7 +21,7 @@ var ErrNoWindows = errors.New("scoop requires a windows build")
type Pipe struct{}
func (Pipe) String() string {
return "creating Scoop Manifest"
return "creating scoop manifest"
}
// Publish scoop manifest

View File

@ -131,12 +131,14 @@ func releaseProject(options releaseOptions) error {
return doRelease(ctx)
}
var bold = color.New(color.Bold)
func doRelease(ctx *context.Context) error {
defer func() { cli.Default.Padding = 3 }()
var release = func() error {
for _, pipe := range pipeline.Pipeline {
cli.Default.Padding = 3
log.Infof(color.New(color.Bold).Sprint(strings.ToUpper(pipe.String())))
log.Infof(bold.Sprint(strings.ToUpper(pipe.String())))
cli.Default.Padding = 6
if err := handle(pipe.Run(ctx)); err != nil {
return err