mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-15 13:53:25 +02:00
Bumps [github.com/atc0005/go-teams-notify/v2](https://github.com/atc0005/go-teams-notify) from 2.6.1 to 2.7.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/atc0005/go-teams-notify/releases">github.com/atc0005/go-teams-notify/v2's releases</a>.</em></p> <blockquote> <h2>v2.7.0</h2> <h2>Added</h2> <ul> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/134">GH-134</a>) Allow setting user agent, fallback to project-specific default value</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/135">GH-135</a>) Allow overriding default <code>http.Client</code></li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/157">GH-157</a>) Add <code>Adaptive Card</code> message format support <ul> <li>see also discussion from <a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/127">GH-127</a>, including feedback from <a href="https://github.com/ghokun"><code>@ghokun</code></a></li> </ul> </li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/169">GH-169</a>) Added YAML en(de)coding support to <code>MessageCard</code> <ul> <li>credit: <a href="https://github.com/pcanilho"><code>@pcanilho</code></a></li> </ul> </li> </ul> <h2>Changed</h2> <ul> <li>Dependencies <ul> <li><code>github.com/stretchr/testify</code> <ul> <li><code>v1.7.0</code> to <code>v1.8.1</code></li> </ul> </li> </ul> </li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/154">GH-154</a>) Deprecate API interface, expose underlying "Teams" client</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/183">GH-183</a>) Update Makefile and GitHub Actions Workflows</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/190">GH-190</a>) Refactor GitHub Actions workflows to import logic</li> </ul> <h2>Fixed</h2> <ul> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/166">GH-166</a>) Update <code>lintinstall</code> Makefile recipe</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/184">GH-184</a>) Apply Go 1.19 specific doc comments linting fixes</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/176">GH-176</a>) <code>./send_test.go:238:8: second argument to errors.As should not be *error</code></li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/179">GH-179</a>) Wrong json key name for URL (uses uri instead) <ul> <li>credit: <a href="https://github.com/janfonas"><code>@janfonas</code></a></li> </ul> </li> </ul> <h2>References</h2> <ul> <li>See the <a href="https://github.com/atc0005/go-teams-notify/milestone/11?closed=1"><code>v2.7.0</code> milestone</a> for the issues associated with this release.</li> <li>See our <a href="https://github.com/atc0005/go-teams-notify/blob/master/CHANGELOG.md">CHANGELOG</a> for more information.</li> </ul> <h2>v2.7.0-rc.2</h2> <h2>WARNING</h2> <p>This is a release candidate (RC) release. Unless issues are discovered & reported, this will become the next v2.7.0 stable release.</p> <p>Please test and provide feedback so that any blocking issues can be resolved before the v2.7.0 release.</p> <p>Thanks in advance!</p> <h2>Changes for the <code>v2.7.0-rc.2</code> release</h2> <ul> <li>dependency updates</li> <li>CI tweaks/enhancements</li> </ul> <h2>Changes for the <code>v2.7.0-rc.1</code> release</h2> <ul> <li>Go 1.19 specific linting fixes</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/atc0005/go-teams-notify/blob/master/CHANGELOG.md">github.com/atc0005/go-teams-notify/v2's changelog</a>.</em></p> <blockquote> <h2>[v2.7.0] - 2022-12-12</h2> <h3>Added</h3> <ul> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/134">GH-134</a>) Allow setting user agent, fallback to project-specific default value</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/135">GH-135</a>) Allow overriding default <code>http.Client</code></li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/157">GH-157</a>) Add <code>Adaptive Card</code> message format support <ul> <li>see also discussion from <a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/127">GH-127</a>, including feedback from <a href="https://github.com/ghokun"><code>@ghokun</code></a></li> </ul> </li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/169">GH-169</a>) Added YAML en(de)coding support to <code>MessageCard</code> <ul> <li>credit: <a href="https://github.com/pcanilho"><code>@pcanilho</code></a></li> </ul> </li> </ul> <h3>Changed</h3> <ul> <li>Dependencies <ul> <li><code>github.com/stretchr/testify</code> <ul> <li><code>v1.7.0</code> to <code>v1.8.1</code></li> </ul> </li> </ul> </li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/154">GH-154</a>) Deprecate API interface, expose underlying "Teams" client</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/183">GH-183</a>) Update Makefile and GitHub Actions Workflows</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/190">GH-190</a>) Refactor GitHub Actions workflows to import logic</li> </ul> <h3>Fixed</h3> <ul> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/166">GH-166</a>) Update <code>lintinstall</code> Makefile recipe</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/184">GH-184</a>) Apply Go 1.19 specific doc comments linting fixes</li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/176">GH-176</a>) <code>./send_test.go:238:8: second argument to errors.As should not be *error</code></li> <li>(<a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/179">GH-179</a>) Wrong json key name for URL (uses uri instead) <ul> <li>credit: <a href="https://github.com/janfonas"><code>@janfonas</code></a></li> </ul> </li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="c205f3b9c9
"><code>c205f3b</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/195">#195</a> from atc0005/update-changelog-for-v2.7.0-release</li> <li><a href="8ea4c384a6
"><code>8ea4c38</code></a> Update CHANGELOG for v2.7.0 release</li> <li><a href="76cdfd663d
"><code>76cdfd6</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/191">#191</a> from atc0005/dependabot/go_modules/master/github.com/...</li> <li><a href="0ae634df2e
"><code>0ae634d</code></a> go.mod: bump github.com/stretchr/testify from 1.8.0 to 1.8.1</li> <li><a href="dece5c5e6f
"><code>dece5c5</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/190">#190</a> from atc0005/ghaw-refactor</li> <li><a href="00f3f9dc82
"><code>00f3f9d</code></a> Refactor GitHub Actions workflows to import logic</li> <li><a href="8524906f8a
"><code>8524906</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/189">#189</a> from atc0005/dependabot/github_actions/master/github/...</li> <li><a href="10f4c0e5f9
"><code>10f4c0e</code></a> ghaw: bump github/codeql-action from 2.1.24 to 2.1.25</li> <li><a href="bf0a4f6096
"><code>bf0a4f6</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/atc0005/go-teams-notify/issues/188">#188</a> from atc0005/dependabot/github_actions/master/github/...</li> <li><a href="81f64b7826
"><code>81f64b7</code></a> ghaw: bump github/codeql-action from 2.1.23 to 2.1.24</li> <li>Additional commits viewable in <a href="https://github.com/atc0005/go-teams-notify/compare/v2.6.1...v2.7.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/atc0005/go-teams-notify/v2&package-manager=go_modules&previous-version=2.6.1&new-version=2.7.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Carlos A Becker <caarlos0@users.noreply.github.com>
84 lines
2.5 KiB
Go
84 lines
2.5 KiB
Go
package teams
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
goteamsnotify "github.com/atc0005/go-teams-notify/v2"
|
|
"github.com/atc0005/go-teams-notify/v2/messagecard"
|
|
"github.com/caarlos0/env/v6"
|
|
"github.com/caarlos0/log"
|
|
"github.com/goreleaser/goreleaser/internal/tmpl"
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
)
|
|
|
|
const (
|
|
defaultColor = "#2D313E"
|
|
defaultIcon = "https://goreleaser.com/static/avatar.png"
|
|
defaultMessageTemplate = `{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}`
|
|
defaultMessageTitle = `{{ .ProjectName }} {{ .Tag }} is out!`
|
|
)
|
|
|
|
type Pipe struct{}
|
|
|
|
func (Pipe) String() string { return "teams" }
|
|
func (Pipe) Skip(ctx *context.Context) bool { return !ctx.Config.Announce.Teams.Enabled }
|
|
|
|
type Config struct {
|
|
Webhook string `env:"TEAMS_WEBHOOK,notEmpty"`
|
|
}
|
|
|
|
func (p Pipe) Default(ctx *context.Context) error {
|
|
if ctx.Config.Announce.Teams.MessageTemplate == "" {
|
|
ctx.Config.Announce.Teams.MessageTemplate = defaultMessageTemplate
|
|
}
|
|
if ctx.Config.Announce.Teams.TitleTemplate == "" {
|
|
ctx.Config.Announce.Teams.TitleTemplate = defaultMessageTitle
|
|
}
|
|
if ctx.Config.Announce.Teams.IconURL == "" {
|
|
ctx.Config.Announce.Teams.IconURL = defaultIcon
|
|
}
|
|
if ctx.Config.Announce.Teams.Color == "" {
|
|
ctx.Config.Announce.Teams.Color = defaultColor
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p Pipe) Announce(ctx *context.Context) error {
|
|
title, err := tmpl.New(ctx).Apply(ctx.Config.Announce.Teams.TitleTemplate)
|
|
if err != nil {
|
|
return fmt.Errorf("announce: failed to announce to teams: %w", err)
|
|
}
|
|
|
|
msg, err := tmpl.New(ctx).Apply(ctx.Config.Announce.Teams.MessageTemplate)
|
|
if err != nil {
|
|
return fmt.Errorf("announce: failed to announce to teams: %w", err)
|
|
}
|
|
|
|
var cfg Config
|
|
if err := env.Parse(&cfg); err != nil {
|
|
return fmt.Errorf("announce: failed to announce to teams: %w", err)
|
|
}
|
|
|
|
log.Infof("posting: '%s'", msg)
|
|
|
|
client := goteamsnotify.NewTeamsClient()
|
|
msgCard := messagecard.NewMessageCard()
|
|
msgCard.Summary = title
|
|
msgCard.ThemeColor = ctx.Config.Announce.Teams.Color
|
|
|
|
messageCardSection := messagecard.NewSection()
|
|
messageCardSection.ActivityTitle = title
|
|
messageCardSection.ActivityText = msg
|
|
messageCardSection.Markdown = true
|
|
messageCardSection.ActivityImage = ctx.Config.Announce.Teams.IconURL
|
|
err = msgCard.AddSection(messageCardSection)
|
|
if err != nil {
|
|
return fmt.Errorf("announce: failed to announce to teams: %w", err)
|
|
}
|
|
err = client.Send(cfg.Webhook, msgCard)
|
|
if err != nil {
|
|
return fmt.Errorf("announce: failed to announce to teams: %w", err)
|
|
}
|
|
return nil
|
|
}
|