2021-05-25 00:19:06 -03:00
|
|
|
// Package announce contains the announcing pipe.
|
|
|
|
package announce
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2021-09-18 10:21:29 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/middleware/errhandler"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/middleware/logging"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/middleware/skip"
|
2021-09-11 14:36:40 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/discord"
|
2021-09-29 01:18:35 +02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/mattermost"
|
2021-08-31 10:49:22 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/reddit"
|
2021-09-01 22:46:25 +03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/slack"
|
2021-09-15 21:38:58 +03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/smtp"
|
2021-09-12 19:59:26 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/teams"
|
2021-05-25 00:19:06 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/twitter"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Announcer should be implemented by pipes that want to announce releases.
|
|
|
|
type Announcer interface {
|
|
|
|
fmt.Stringer
|
|
|
|
|
|
|
|
Announce(ctx *context.Context) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// nolint: gochecknoglobals
|
|
|
|
var announcers = []Announcer{
|
2021-09-11 14:36:40 -03:00
|
|
|
// XXX: keep asc sorting
|
|
|
|
discord.Pipe{},
|
2021-09-29 01:18:35 +02:00
|
|
|
mattermost.Pipe{},
|
2021-09-11 14:36:40 -03:00
|
|
|
reddit.Pipe{},
|
|
|
|
slack.Pipe{},
|
2021-09-15 21:38:58 +03:00
|
|
|
smtp.Pipe{},
|
2021-09-13 00:57:58 +02:00
|
|
|
teams.Pipe{},
|
2021-09-12 19:59:26 -03:00
|
|
|
twitter.Pipe{},
|
2021-05-25 00:19:06 -03:00
|
|
|
}
|
|
|
|
|
2021-09-18 10:21:29 -03:00
|
|
|
// Pipe that announces releases.
|
|
|
|
type Pipe struct{}
|
|
|
|
|
|
|
|
func (Pipe) String() string { return "announcing" }
|
|
|
|
func (Pipe) Skip(ctx *context.Context) bool { return ctx.SkipAnnounce }
|
|
|
|
|
2021-05-25 00:19:06 -03:00
|
|
|
// Run the pipe.
|
|
|
|
func (Pipe) Run(ctx *context.Context) error {
|
|
|
|
for _, announcer := range announcers {
|
2021-09-18 10:21:29 -03:00
|
|
|
if err := skip.Maybe(
|
|
|
|
announcer,
|
|
|
|
logging.Log(
|
|
|
|
announcer.String(),
|
|
|
|
errhandler.Handle(announcer.Announce),
|
|
|
|
logging.ExtraPadding,
|
|
|
|
),
|
2021-05-25 00:19:06 -03:00
|
|
|
)(ctx); err != nil {
|
|
|
|
return fmt.Errorf("%s: failed to announce release: %w", announcer.String(), err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|