/
announce.go
47 lines (39 loc) · 1.14 KB
/
announce.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Package announce contains the announcing pipe.
package announce
import (
"fmt"
"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 twitter
slack.Pipe{}, // announce to slack
}
// 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
}