1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/pipe/publish/publish.go

41 lines
878 B
Go
Raw Normal View History

2018-10-05 14:22:53 +02:00
// Package publish contains the publishing pipe.
package publish
import (
"fmt"
"github.com/goreleaser/goreleaser/internal/pipe"
"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
}
var publishers = []Publisher{}
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
if ctx.SkipPublish {
return pipe.ErrSkipPublishEnabled
}
for _, publisher := range publishers {
if err := publisher.Publish(ctx); err != nil {
return errors.Wrapf(err, "failed to publish artifacts for %s", publisher.String())
}
}
return nil
}