1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-03 13:11:48 +02:00
Engin Diri 311479504e
feat: announce: discord (#2478)
Signed-off-by: Engin Diri <engin.diri@mail.schwarz>
2021-09-11 17:23:54 +00:00

50 lines
1.2 KiB
Go

// Package announce contains the announcing pipe.
package announce
import (
"fmt"
"github.com/goreleaser/goreleaser/internal/pipe/discord"
"github.com/goreleaser/goreleaser/internal/middleware"
"github.com/goreleaser/goreleaser/internal/pipe/reddit"
"github.com/goreleaser/goreleaser/internal/pipe/slack"
"github.com/goreleaser/goreleaser/internal/pipe/twitter"
"github.com/goreleaser/goreleaser/pkg/context"
)
// Pipe that announces releases.
type Pipe struct{}
func (Pipe) String() string {
return "announcing"
}
// 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{
twitter.Pipe{}, // announce to twitter
reddit.Pipe{}, // announce to reddit
slack.Pipe{}, // announce to slack
discord.Pipe{}, // announce to discord
}
// Run the pipe.
func (Pipe) Run(ctx *context.Context) error {
for _, announcer := range announcers {
if err := middleware.Logging(
announcer.String(),
middleware.ErrHandler(announcer.Announce),
middleware.ExtraPadding,
)(ctx); err != nil {
return fmt.Errorf("%s: failed to announce release: %w", announcer.String(), err)
}
}
return nil
}