Files
releaser/internal/notify/telegram.go
T
k3nny d790a9edfe
ci / vet, staticcheck, test, build (push) Successful in 4m10s
docs / Build and deploy docs (push) Failing after 10s
release / Build and publish release (push) Successful in 5m9s
feat(notify): release v1.8.0 — Slack/Teams/Google Chat/Telegram/webhook notifications
- Add internal/notify package: best-effort release notifications to Slack, Microsoft Teams, Google Chat, Telegram, and a generic JSON webhook; every target is independently opt-in and a failed notification never fails the release
- Add notify config section (slack_webhook_url, teams_webhook_url, google_chat_webhook_url, telegram_bot_token/telegram_chat_id, webhook_url) with matching env var fallbacks; 100% coverage plus FuzzMessagePayloads
- Wire notification sending into run() — fires after tag+push (including --no-release), skipped on --no-push/--no-commit since nothing was published yet
- Document the notify section in README, Hugo docs, and .releaser.yml template; update CLAUDE.md architecture/fuzzing tables
- Also commit the Apache License 2.0 docs-site footer link (docs/hugo.toml geekdocContentLicense), left uncommitted from a prior change

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-12 13:55:57 +02:00

31 lines
966 B
Go

package notify
import (
"context"
"fmt"
)
// telegramAPIBase is the Telegram Bot API host. Overridden in tests.
var telegramAPIBase = "https://api.telegram.org"
// telegramPayload matches the Telegram Bot API sendMessage contract. Notes
// are sent as plain text (no parse_mode) — release notes come from arbitrary
// commit messages and are not guaranteed to be valid Telegram Markdown/HTML,
// and a malformed entity makes the whole request fail with a 400.
type telegramPayload struct {
ChatID string `json:"chat_id"`
Text string `json:"text"`
}
func newTelegramPayload(chatID string, msg Message) telegramPayload {
return telegramPayload{
ChatID: chatID,
Text: fmt.Sprintf("Released %s\n\n%s", msg.Version, msg.Notes),
}
}
func sendTelegram(ctx context.Context, botToken, chatID string, msg Message) error {
url := fmt.Sprintf("%s/bot%s/sendMessage", telegramAPIBase, botToken)
return postJSON(ctx, url, newTelegramPayload(chatID, msg))
}