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