1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-03 13:11:48 +02:00

68 lines
1.8 KiB
Go
Raw Normal View History

2018-10-05 09:22:53 -03:00
// Package publish contains the publishing pipe.
package publish
import (
"fmt"
"github.com/goreleaser/goreleaser/internal/middleware"
2018-10-05 09:22:53 -03:00
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/pipe/artifactory"
"github.com/goreleaser/goreleaser/internal/pipe/blob"
2018-10-10 12:47:31 -03:00
"github.com/goreleaser/goreleaser/internal/pipe/brew"
2018-10-20 13:45:31 -03:00
"github.com/goreleaser/goreleaser/internal/pipe/docker"
2018-10-16 20:50:49 -03:00
"github.com/goreleaser/goreleaser/internal/pipe/put"
2018-10-16 20:39:10 -03:00
"github.com/goreleaser/goreleaser/internal/pipe/release"
2018-10-16 20:50:49 -03:00
"github.com/goreleaser/goreleaser/internal/pipe/s3"
2018-10-10 12:47:31 -03:00
"github.com/goreleaser/goreleaser/internal/pipe/scoop"
2018-10-20 14:25:46 -03:00
"github.com/goreleaser/goreleaser/internal/pipe/snapcraft"
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 {
2018-11-03 15:25:01 -03:00
return "publishing"
2018-10-05 09:22:53 -03:00
}
// 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-11-07 22:04:49 -02:00
// nolint: gochecknoglobals
2018-10-10 12:47:31 -03:00
var publishers = []Publisher{
2018-10-16 20:50:49 -03:00
s3.Pipe{},
blob.Pipe{},
2018-10-16 20:50:49 -03:00
put.Pipe{},
artifactory.Pipe{},
2018-10-20 13:45:31 -03:00
docker.Pipe{},
2018-10-20 14:25:46 -03:00
snapcraft.Pipe{},
// This should be one of the last steps
release.Pipe{},
// brew and scoop use the release URL, so, they should be last
brew.Pipe{},
scoop.Pipe{},
2018-10-10 12:47:31 -03:00
}
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 {
if err := middleware.Logging(
publisher.String(),
middleware.ErrHandler(publisher.Publish),
middleware.ExtraPadding,
)(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
}