github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/internal/pipe/publish/publish.go (about) 1 // Package publish contains the publishing pipe. 2 package publish 3 4 import ( 5 "fmt" 6 7 "github.com/goreleaser/goreleaser/internal/middleware/errhandler" 8 "github.com/goreleaser/goreleaser/internal/middleware/logging" 9 "github.com/goreleaser/goreleaser/internal/middleware/skip" 10 "github.com/goreleaser/goreleaser/internal/pipe/artifactory" 11 "github.com/goreleaser/goreleaser/internal/pipe/blob" 12 "github.com/goreleaser/goreleaser/internal/pipe/brew" 13 "github.com/goreleaser/goreleaser/internal/pipe/custompublishers" 14 "github.com/goreleaser/goreleaser/internal/pipe/docker" 15 "github.com/goreleaser/goreleaser/internal/pipe/milestone" 16 "github.com/goreleaser/goreleaser/internal/pipe/release" 17 "github.com/goreleaser/goreleaser/internal/pipe/scoop" 18 "github.com/goreleaser/goreleaser/internal/pipe/sign" 19 "github.com/goreleaser/goreleaser/internal/pipe/snapcraft" 20 "github.com/goreleaser/goreleaser/internal/pipe/upload" 21 "github.com/goreleaser/goreleaser/pkg/context" 22 ) 23 24 // Publisher should be implemented by pipes that want to publish artifacts. 25 type Publisher interface { 26 fmt.Stringer 27 28 // Default sets the configuration defaults 29 Publish(ctx *context.Context) error 30 } 31 32 // nolint: gochecknoglobals 33 var publishers = []Publisher{ 34 blob.Pipe{}, 35 upload.Pipe{}, 36 custompublishers.Pipe{}, 37 artifactory.Pipe{}, 38 docker.Pipe{}, 39 docker.ManifestPipe{}, 40 sign.DockerPipe{}, 41 snapcraft.Pipe{}, 42 // This should be one of the last steps 43 release.Pipe{}, 44 // brew and scoop use the release URL, so, they should be last 45 brew.Pipe{}, 46 scoop.Pipe{}, 47 milestone.Pipe{}, 48 } 49 50 // Pipe that publishes artifacts. 51 type Pipe struct{} 52 53 func (Pipe) String() string { return "publishing" } 54 func (Pipe) Skip(ctx *context.Context) bool { return ctx.SkipPublish } 55 56 func (Pipe) Run(ctx *context.Context) error { 57 for _, publisher := range publishers { 58 if err := skip.Maybe( 59 publisher, 60 logging.Log( 61 publisher.String(), 62 errhandler.Handle(publisher.Publish), 63 logging.ExtraPadding, 64 ), 65 )(ctx); err != nil { 66 return fmt.Errorf("%s: failed to publish artifacts: %w", publisher.String(), err) 67 } 68 } 69 return nil 70 }