Skip to content

Add Slack webhook integration for release notifications #2

@ygpark80

Description

@ygpark80

Overview

Add Slack integration to the bump CLI tool to send notifications about version bumps, releases, and changelog updates. The integration should use Slack webhooks for simplicity, avoiding the complexity of managing Slack API tokens and OAuth flows.

Core Requirements

Slack Webhook Integration

  • Webhook-based approach: Use Slack Incoming Webhooks instead of Slack API
    • Simpler setup: only requires a webhook URL
    • No token management or OAuth complexity
    • Easy to configure via environment variable or CLI flag
  • Webhook URL Configuration:
    • Support via environment variable: SLACK_WEBHOOK_URL
    • Support via CLI flag: --slack-webhook <url>
    • Support via config file (optional): .bump/config.toml or similar

Notification Types

The CLI should send Slack notifications for:

  1. Version Bump Notifications:

    • When a new version is detected or created
    • Include: old version → new version
    • Package name
    • Registry source (public/private)
  2. Git Tag Creation:

    • When a new version tag is created
    • Include: tag name, commit hash, author
  3. Changelog Generation:

    • When changelog is generated
    • Include: summary of changes (number of commits, files changed)
    • Link to changelog file location (if applicable)
  4. Full Release Workflow:

    • Combined notification for complete release process
    • Include: version, tag, changelog summary, and any relevant links

Message Format

  • Rich formatting: Use Slack's Block Kit or markdown formatting
  • Structured messages: Include:
    • Title/header with emoji indicators
    • Key information in structured sections
    • Links to relevant resources (GitHub, changelog, etc.)
    • Color coding (success = green, info = blue, warning = yellow)
  • Optional attachments: Include changelog preview or summary

Command Integration

Add Slack notification support to existing commands:

# Version command with Slack notification
bump version --slack-webhook <url>
# or use environment variable
SLACK_WEBHOOK_URL=<url> bump version

# Tag command with Slack notification
bump tag --version 1.2.3 --slack-webhook <url>

# Changelog with Slack notification
bump changelog --slack-webhook <url> --output ./CHANGELOG.md

# Full workflow with Slack notification
bump full --slack-webhook <url> --output ./changelog.md

Configuration Options

  • Enable/disable notifications: --slack flag to enable, or auto-detect from webhook URL presence
  • Customize message format: Optional config for message templates
  • Channel targeting: Support for different webhook URLs per channel (via config)
  • Quiet mode: --no-slack flag to explicitly disable notifications

Technical Requirements

Implementation

  • HTTP Client: Use reqwest (already in requirements) to POST to webhook URL
  • Error Handling:
    • Graceful failure: if Slack notification fails, don't fail the entire bump operation
    • Log errors but continue with version/tag/changelog operations
    • Clear error messages if webhook URL is invalid
  • Non-blocking: Consider async notification (don't block main operation)
  • Retry logic: Optional retry for failed webhook requests (with backoff)

Message Payload

Use Slack's webhook payload format:

{
  "text": "Release Notification",
  "blocks": [
    {
      "type": "header",
      "text": {
        "type": "plain_text",
        "text": "🚀 New Release: v1.2.3"
      }
    },
    {
      "type": "section",
      "fields": [
        {
          "type": "mrkdwn",
          "text": "*Package:* `@circlesac/bump`"
        },
        {
          "type": "mrkdwn",
          "text": "*Version:* `1.2.0` → `1.2.3`"
        }
      ]
    }
  ]
}

Security Considerations

  • Webhook URL protection: Don't log or expose webhook URLs in error messages
  • Sensitive data: Be careful not to include sensitive information in notifications
  • Optional validation: Validate webhook URL format before sending

Usage Examples

# Set webhook URL via environment variable
export SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
bump full --output ./changelog.md

# Use webhook URL via CLI flag
bump version --slack-webhook https://hooks.slack.com/services/YOUR/WEBHOOK/URL

# Disable Slack notifications explicitly
bump full --no-slack --output ./changelog.md

# Different webhooks for different operations
bump tag --version 1.2.3 --slack-webhook https://hooks.slack.com/services/RELEASE/WEBHOOK
bump changelog --slack-webhook https://hooks.slack.com/services/CHANGELOG/WEBHOOK

Integration Points

CI/CD Integration

  • GitHub Actions: Easy to set webhook URL as secret and pass to CLI
  • Non-interactive mode: Works seamlessly in automated workflows
  • Exit codes: Slack failures don't affect exit codes (operations succeed even if notification fails)

Config File Support (Optional)

Support configuration via .bump/config.toml:

[slack]
webhook_url = "https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
enabled = true
channel = "#releases"

Success Criteria

  1. ✅ Successfully sends Slack notifications via webhook for version bumps
  2. ✅ Supports webhook URL via environment variable and CLI flag
  3. ✅ Gracefully handles webhook failures without breaking main operations
  4. ✅ Provides rich, formatted messages with relevant information
  5. ✅ Integrates seamlessly with existing bump commands
  6. ✅ Works in CI/CD environments (non-interactive mode)
  7. ✅ Supports enabling/disabling notifications via flags
  8. ✅ Clear error messages for invalid webhook URLs

Implementation Notes

  • Start simple: Begin with basic text messages, then add Block Kit formatting
  • Error handling: Make Slack notifications non-blocking - if they fail, the bump operation should still succeed
  • Testing: Consider adding a --slack-test flag to send a test notification
  • Documentation: Document how to set up Slack webhooks in the README
  • Optional feature: Make Slack integration optional (don't require it for core functionality)

Why Webhooks Instead of Slack API

  • Simplicity: No OAuth flow, token management, or app installation required
  • Ease of setup: Just create a webhook URL in Slack and use it
  • Less complexity: No need to handle token refresh, scopes, or API rate limits
  • Sufficient for notifications: Webhooks are perfect for one-way notifications
  • CI/CD friendly: Easy to store webhook URLs as secrets in CI systems

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions