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"
|
2024-04-22 22:15:26 -04:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/bluesky"
|
2021-09-11 14:36:40 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/discord"
|
2021-11-06 21:05:04 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/linkedin"
|
2022-11-17 17:40:00 -06:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/mastodon"
|
2021-09-29 01:18:35 +02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/mattermost"
|
2023-02-09 06:11:47 -06:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/opencollective"
|
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-10-07 15:01:31 +02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/telegram"
|
2021-05-25 00:19:06 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/twitter"
|
2022-01-08 18:46:27 +01:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe/webhook"
|
2023-09-16 17:01:20 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/skips"
|
2021-09-28 22:33:04 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/tmpl"
|
2021-05-25 00:19:06 -03:00
|
|
|
"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
|
2024-04-22 22:15:26 -04:00
|
|
|
bluesky.Pipe{},
|
2021-09-11 14:36:40 -03:00
|
|
|
discord.Pipe{},
|
2021-11-06 21:05:04 -03:00
|
|
|
linkedin.Pipe{},
|
2022-11-17 17:40:00 -06:00
|
|
|
mastodon.Pipe{},
|
2021-09-29 01:18:35 +02:00
|
|
|
mattermost.Pipe{},
|
2023-02-09 06:11:47 -06:00
|
|
|
opencollective.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-10-07 15:01:31 +02:00
|
|
|
telegram.Pipe{},
|
2021-09-12 19:59:26 -03:00
|
|
|
twitter.Pipe{},
|
2022-01-08 18:46:27 +01:00
|
|
|
webhook.Pipe{},
|
2021-05-25 00:19:06 -03:00
|
|
|
}
|
|
|
|
|
2021-09-18 10:21:29 -03:00
|
|
|
// Pipe that announces releases.
|
|
|
|
type Pipe struct{}
|
|
|
|
|
2021-09-28 22:33:04 -03:00
|
|
|
func (Pipe) String() string { return "announcing" }
|
|
|
|
|
2023-01-28 23:21:43 -03:00
|
|
|
func (Pipe) Skip(ctx *context.Context) (bool, error) {
|
2023-09-16 17:01:20 -03:00
|
|
|
if skips.Any(ctx, skips.Announce) {
|
2023-01-28 23:21:43 -03:00
|
|
|
return true, nil
|
2021-09-28 22:33:04 -03:00
|
|
|
}
|
2023-01-28 23:21:43 -03:00
|
|
|
return tmpl.New(ctx).Bool(ctx.Config.Announce.Skip)
|
2021-09-28 22:33:04 -03:00
|
|
|
}
|
2021-09-18 10:21:29 -03:00
|
|
|
|
2021-05-25 00:19:06 -03:00
|
|
|
// Run the pipe.
|
|
|
|
func (Pipe) Run(ctx *context.Context) error {
|
2022-12-28 12:24:21 -03:00
|
|
|
memo := errhandler.Memo{}
|
2021-05-25 00:19:06 -03:00
|
|
|
for _, announcer := range announcers {
|
2022-12-28 12:24:21 -03:00
|
|
|
_ = skip.Maybe(
|
2021-09-18 10:21:29 -03:00
|
|
|
announcer,
|
2022-12-28 12:24:21 -03:00
|
|
|
logging.PadLog(announcer.String(), memo.Wrap(announcer.Announce)),
|
|
|
|
)(ctx)
|
|
|
|
}
|
|
|
|
if memo.Error() != nil {
|
|
|
|
return fmt.Errorf("failed to announce release: %w", memo.Error())
|
2021-05-25 00:19:06 -03:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|