2018-10-05 09:22:53 -03:00
|
|
|
// Package publish contains the publishing pipe.
|
|
|
|
package publish
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2018-10-12 00:14:06 -03:00
|
|
|
"github.com/apex/log"
|
2018-10-05 09:22:53 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe"
|
2018-10-10 12:47:31 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/brew"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/scoop"
|
2018-10-05 09:22:53 -03:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Pipe that publishes artifacts
|
|
|
|
type Pipe struct{}
|
|
|
|
|
|
|
|
func (Pipe) String() string {
|
|
|
|
return "publishing artifacts"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Publisher should be implemented by pipes that want to publish artifacts
|
|
|
|
type Publisher interface {
|
|
|
|
fmt.Stringer
|
|
|
|
|
|
|
|
// Default sets the configuration defaults
|
|
|
|
Publish(ctx *context.Context) error
|
|
|
|
}
|
|
|
|
|
2018-10-10 12:47:31 -03:00
|
|
|
var publishers = []Publisher{
|
|
|
|
brew.Pipe{},
|
|
|
|
scoop.Pipe{},
|
|
|
|
}
|
2018-10-05 09:22:53 -03:00
|
|
|
|
|
|
|
// Run the pipe
|
|
|
|
func (Pipe) Run(ctx *context.Context) error {
|
|
|
|
if ctx.SkipPublish {
|
|
|
|
return pipe.ErrSkipPublishEnabled
|
|
|
|
}
|
|
|
|
for _, publisher := range publishers {
|
2018-10-12 00:14:06 -03:00
|
|
|
log.Infof("Publishing %s...", publisher.String())
|
2018-10-05 09:22:53 -03:00
|
|
|
if err := publisher.Publish(ctx); err != nil {
|
2018-10-12 00:14:06 -03:00
|
|
|
return errors.Wrapf(err, "%s: failed to publish artifacts", publisher.String())
|
2018-10-05 09:22:53 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|