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

66 lines
1.8 KiB
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/middleware"
"github.com/goreleaser/goreleaser/internal/pipe/artifactory"
"github.com/goreleaser/goreleaser/internal/pipe/blob"
2018-10-10 17:47:31 +02:00
"github.com/goreleaser/goreleaser/internal/pipe/brew"
"github.com/goreleaser/goreleaser/internal/pipe/custompublishers"
2018-10-20 18:45:31 +02:00
"github.com/goreleaser/goreleaser/internal/pipe/docker"
"github.com/goreleaser/goreleaser/internal/pipe/milestone"
2018-10-17 01:39:10 +02:00
"github.com/goreleaser/goreleaser/internal/pipe/release"
2018-10-10 17:47:31 +02:00
"github.com/goreleaser/goreleaser/internal/pipe/scoop"
2018-10-20 19:25:46 +02:00
"github.com/goreleaser/goreleaser/internal/pipe/snapcraft"
"github.com/goreleaser/goreleaser/internal/pipe/upload"
2018-10-05 14:22:53 +02:00
"github.com/goreleaser/goreleaser/pkg/context"
)
// Pipe that publishes artifacts.
2018-10-05 14:22:53 +02:00
type Pipe struct{}
func (Pipe) String() string {
2018-11-03 20:25:01 +02:00
return "publishing"
2018-10-05 14:22:53 +02:00
}
// Publisher should be implemented by pipes that want to publish artifacts.
2018-10-05 14:22:53 +02:00
type Publisher interface {
fmt.Stringer
// Default sets the configuration defaults
Publish(ctx *context.Context) error
}
2018-11-08 02:04:49 +02:00
// nolint: gochecknoglobals
2018-10-10 17:47:31 +02:00
var publishers = []Publisher{
blob.Pipe{},
upload.Pipe{},
custompublishers.Pipe{},
artifactory.Pipe{},
2018-10-20 18:45:31 +02:00
docker.Pipe{},
docker.ManifestPipe{},
2018-10-20 19:25:46 +02: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{},
milestone.Pipe{},
2018-10-10 17:47:31 +02:00
}
2018-10-05 14:22:53 +02:00
// Run the pipe.
2018-10-05 14:22:53 +02:00
func (Pipe) Run(ctx *context.Context) error {
for _, publisher := range publishers {
if err := middleware.Logging(
publisher.String(),
middleware.ErrHandler(publisher.Publish),
middleware.ExtraPadding,
)(ctx); err != nil {
return fmt.Errorf("%s: failed to publish artifacts: %w", publisher.String(), err)
2018-10-05 14:22:53 +02:00
}
}
return nil
}