1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/internal/pipe/announce/announce.go
Josh Ghiloni de72cab5d9
feat(announce): add BlueSky support (#4779)
<!--

Hi, thanks for contributing!

Please make sure you read our CONTRIBUTING guide.

Also, add tests and the respective documentation changes as well.

-->


<!-- If applied, this commit will... -->

If applied, this commit will allow users to create BlueSky posts
(skeets) about their Goreleaser-built projects

<!-- Why is this change being made? -->

Because I wanted to post to BlueSky when projects I work on relating to
BlueSky are built!

<!-- # Provide links to any relevant tickets, URLs or other resources
-->

Example post made during unit testing (requires an account to see):
https://bsky.app/profile/jaygles.bsky.social/post/3kpv573c2pc2k

---------

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2024-04-22 23:15:26 -03:00

78 lines
2.2 KiB
Go

// Package announce contains the announcing pipe.
package announce
import (
"fmt"
"github.com/goreleaser/goreleaser/internal/middleware/errhandler"
"github.com/goreleaser/goreleaser/internal/middleware/logging"
"github.com/goreleaser/goreleaser/internal/middleware/skip"
"github.com/goreleaser/goreleaser/internal/pipe/bluesky"
"github.com/goreleaser/goreleaser/internal/pipe/discord"
"github.com/goreleaser/goreleaser/internal/pipe/linkedin"
"github.com/goreleaser/goreleaser/internal/pipe/mastodon"
"github.com/goreleaser/goreleaser/internal/pipe/mattermost"
"github.com/goreleaser/goreleaser/internal/pipe/opencollective"
"github.com/goreleaser/goreleaser/internal/pipe/reddit"
"github.com/goreleaser/goreleaser/internal/pipe/slack"
"github.com/goreleaser/goreleaser/internal/pipe/smtp"
"github.com/goreleaser/goreleaser/internal/pipe/teams"
"github.com/goreleaser/goreleaser/internal/pipe/telegram"
"github.com/goreleaser/goreleaser/internal/pipe/twitter"
"github.com/goreleaser/goreleaser/internal/pipe/webhook"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/tmpl"
"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{
// XXX: keep asc sorting
bluesky.Pipe{},
discord.Pipe{},
linkedin.Pipe{},
mastodon.Pipe{},
mattermost.Pipe{},
opencollective.Pipe{},
reddit.Pipe{},
slack.Pipe{},
smtp.Pipe{},
teams.Pipe{},
telegram.Pipe{},
twitter.Pipe{},
webhook.Pipe{},
}
// Pipe that announces releases.
type Pipe struct{}
func (Pipe) String() string { return "announcing" }
func (Pipe) Skip(ctx *context.Context) (bool, error) {
if skips.Any(ctx, skips.Announce) {
return true, nil
}
return tmpl.New(ctx).Bool(ctx.Config.Announce.Skip)
}
// Run the pipe.
func (Pipe) Run(ctx *context.Context) error {
memo := errhandler.Memo{}
for _, announcer := range announcers {
_ = skip.Maybe(
announcer,
logging.PadLog(announcer.String(), memo.Wrap(announcer.Announce)),
)(ctx)
}
if memo.Error() != nil {
return fmt.Errorf("failed to announce release: %w", memo.Error())
}
return nil
}