|
| 1 | +# Discord Release Notifications |
| 2 | + |
| 3 | +This document describes the automated Discord notification system for GoFr releases. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +GoFr automatically posts release announcements to Discord when a new version is published on GitHub. The system uses a custom Go tool that handles message splitting, Markdown preservation, and retry logic. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **UTF-8 Safe**: Correctly handles emojis and multi-byte Unicode characters |
| 12 | +- **Markdown Preservation**: Intelligently splits messages while preserving code block formatting |
| 13 | +- **Custom Format**: Posts with `# [🌟 GoFr {version} Released! 🌟](link)` heading |
| 14 | +- **@everyone Mention**: Notifies all Discord members |
| 15 | +- **Retry Logic**: Automatically retries failed posts (3 attempts) |
| 16 | +- **Discord Limit Handling**: Splits messages >2000 characters across multiple posts |
| 17 | + |
| 18 | +## Setup |
| 19 | + |
| 20 | +### 1. Create Discord Webhook |
| 21 | + |
| 22 | +1. Go to your Discord server → Server Settings → Integrations → Webhooks |
| 23 | +2. Click "New Webhook" |
| 24 | +3. Configure the webhook: |
| 25 | + - Name: `GoFr Releases` |
| 26 | + - Channel: Select your releases channel |
| 27 | +4. Copy the webhook URL |
| 28 | + |
| 29 | +### 2. Add GitHub Secret |
| 30 | + |
| 31 | +1. Go to GitHub repository → Settings → Secrets and variables → Actions |
| 32 | +2. Click "New repository secret" |
| 33 | +3. Add: |
| 34 | + - **Name**: `DISCORD_WEBHOOK` |
| 35 | + - **Value**: Your webhook URL from step 1 |
| 36 | + |
| 37 | +## How It Works |
| 38 | + |
| 39 | +The workflow is triggered automatically when a release is published: |
| 40 | + |
| 41 | +1. GitHub Actions workflow starts (`.github/workflows/discord-release-notification.yml`) |
| 42 | +2. Go tool reads release data from environment variables |
| 43 | +3. Constructs formatted message with header and release body |
| 44 | +4. Splits message if needed (respecting Markdown and 2000 char limit) |
| 45 | +5. Posts to Discord with retry logic |
| 46 | + |
| 47 | +## Message Format |
| 48 | + |
| 49 | +``` |
| 50 | +@everyone |
| 51 | +
|
| 52 | +# [🌟 GoFr v1.26.0 Released! 🌟](https://github.com/gofr-dev/gofr/releases/tag/v1.26.0) |
| 53 | +
|
| 54 | +# **Release v1.50.2** |
| 55 | +
|
| 56 | +## 🚀 Enhancements |
| 57 | +... |
| 58 | +``` |
| 59 | + |
| 60 | +## Testing |
| 61 | + |
| 62 | +To test the workflow: |
| 63 | + |
| 64 | +1. Create a test release on GitHub |
| 65 | +2. Check your Discord channel for the notification |
| 66 | +3. Verify formatting and links are correct |
| 67 | + |
| 68 | +## Future Enhancements |
| 69 | + |
| 70 | +- LinkedIn integration for professional visibility |
| 71 | +- X (Twitter) integration for thread-based announcements |
| 72 | +- Support for additional platforms (Slack, Telegram) |
| 73 | + |
| 74 | +## Technical Details |
| 75 | + |
| 76 | +- **Implementation**: `.github/workflows/scripts/discord_notifier.go` |
| 77 | +- **Tests**: `.github/workflows/scripts/discord_notifier_test.go` |
| 78 | +- **Test Coverage**: 55.2% |
| 79 | +- **Language**: Go (for reliability and Unicode support) |
0 commit comments