Skip to content

ci: announce releases to Telegram - #1398

Merged
DZakh merged 7 commits into
mainfrom
ci/telegram-release-announcements
Jul 17, 2026
Merged

ci: announce releases to Telegram#1398
DZakh merged 7 commits into
mainfrom
ci/telegram-release-announcements

Conversation

@Jordy-Baby

@Jordy-Baby Jordy-Baby commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Adds a Telegram counterpart to the Discord release workflow. On a published release it posts major and minor releases (exact X.Y.0) to the Telegram community via the Bot API.

  • Same gate as discord-release.yml: skips patch releases and prereleases (alpha/rc)
  • Sends the release title, notes, and a GitHub link as Telegram HTML, with a plain text fallback; sized to fit the 4096 unit limit
  • Can be run manually against an existing tag to check the message, printing it to the job log rather than sending by default
  • Requires repo secrets: TELEGRAM_RELEASE_BOT_TOKEN, TELEGRAM_RELEASE_CHAT_ID (optional TELEGRAM_RELEASE_TOPIC_ID for a forum topic)

Validated against all 206 historical releases: 38 would post, matching the Discord workflow.

Summary by CodeRabbit

  • New Features
    • Added automated Telegram announcements for newly published GitHub releases, with a manual option to trigger announcements on demand.
    • Announcements are sent only for non-draft releases whose tag matches X.Y.0 (with an optional leading v removed); others are skipped.
    • Release messages include HTML-formatted, truncated release notes plus a “View on GitHub” link, with Telegram size-limit handling and safe formatting fallbacks.
    • Optionally posts to a configured Telegram thread and supports a dry-run mode that logs the message without sending.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A GitHub Actions workflow filters eligible releases, formats release notes within Telegram’s UTF-16 size limit, supports manual dry runs, and sends announcements with optional topic routing.

Changes

Telegram release announcements

Layer / File(s) Summary
Release event filtering
.github/workflows/telegram-release.yml
Configures published-release and manual triggers, skips drafts, and selects non-prerelease X.Y.0 tags after stripping a leading v.
Telegram message formatting
.github/workflows/telegram-release.yml
Retrieves notes, converts Markdown-like content to Telegram HTML, enforces size limits, provides plain-text fallback handling, and supports dry runs.
Telegram message delivery
.github/workflows/telegram-release.yml
Sends URL-encoded messages through the Telegram Bot API with optional topic routing and request timeouts.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubRelease
  participant GitHubActions
  participant TelegramBotAPI
  GitHubRelease->>GitHubActions: published release event
  GitHubActions->>GitHubActions: filter tag and prerelease status
  GitHubActions->>GitHubActions: format and truncate release message
  GitHubActions->>TelegramBotAPI: send formatted announcement
Loading

Possibly related PRs

Suggested reviewers: dzakh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a Telegram release announcement workflow.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/telegram-release.yml:
- Line 66: The Telegram API request in the curl invocation lacks explicit
timeout limits and may hang indefinitely. Update the curl command near the
sendMessage request to add both --connect-timeout and --max-time values
alongside --retry 3, defining suitable connection and total request limits for
each attempt.
- Line 66: Remove the --retry 3 option from the Telegram sendMessage curl
invocation in the workflow, leaving the POST as a single attempt; do not add
retries unless an idempotent deduplication mechanism is implemented first.
- Around line 48-57: The fixed max_body in the message construction can allow
the rendered Telegram message to exceed 4096 characters when TITLE or URL is
long. In the message-building block, compute max_body from the 4096-character
limit minus the lengths of header and link plus the separator characters, clamp
it to a nonnegative value, then truncate body using that calculated budget
before assembling message.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbfa2e82-d9cd-42e6-bb19-66c1b0c39831

📥 Commits

Reviewing files that changed from the base of the PR and between 00bb717 and 3842005.

📒 Files selected for processing (1)
  • .github/workflows/telegram-release.yml

Comment thread .github/workflows/telegram-release.yml Outdated
Comment thread .github/workflows/telegram-release.yml Outdated
@Jordy-Baby
Jordy-Baby force-pushed the ci/telegram-release-announcements branch from 3842005 to 3aac789 Compare July 10, 2026 11:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/telegram-release.yml:
- Around line 55-60: Move truncation from the raw body block to the final
assembled message after HTML escaping and the esc+awk pipeline. Update the
release workflow’s message construction so the completed message is capped at
Telegram’s 4096-character limit, preserving the existing truncation notice while
ensuring the escaped output cannot exceed the limit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed7e77e1-ae76-45aa-8359-c794b522fcdb

📥 Commits

Reviewing files that changed from the base of the PR and between 3842005 and 3aac789.

📒 Files selected for processing (1)
  • .github/workflows/telegram-release.yml

Comment thread .github/workflows/telegram-release.yml Outdated
@DZakh

DZakh commented Jul 10, 2026

Copy link
Copy Markdown
Member

It would be nice to fix the code rabbit comments and also make the links to github PRs embedded like #1329

Mirror the Discord release workflow for the Telegram community: post major
and minor releases (exact X.Y.0, no pre-release suffix) to a Telegram chat
via the Bot API. Renders release notes as Telegram HTML (bold headings, code
blocks, inline code). Sizes the body against the 4096 limit with a plain-text
fallback, uses per-call curl timeouts, and does not retry the send to avoid
duplicate posts. Requires TELEGRAM_RELEASE_BOT_TOKEN and
TELEGRAM_RELEASE_CHAT_ID (optional TELEGRAM_RELEASE_TOPIC_ID for forum groups).
@Jordy-Baby
Jordy-Baby force-pushed the ci/telegram-release-announcements branch from 73c300b to 66322ce Compare July 10, 2026 12:34
@Jordy-Baby
Jordy-Baby enabled auto-merge (squash) July 10, 2026 12:36
@Jordy-Baby

Copy link
Copy Markdown
Contributor Author

@DZakh done 🫡

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/telegram-release.yml:
- Around line 69-72: Fix the truncation note in the shell block containing the
body length check so the continuation line does not include YAML indentation in
the announcement. Build the two-line note without preserving leading
whitespace—such as by using a shell-safe concatenation or stripping
indentation—while retaining the intended newline before “… read the full notes
on GitHub”.
- Around line 91-95: Update the plain-text fallback truncation in the Telegram
release step to respect Telegram’s 4096 UTF-16-unit limit rather than Bash
character counts. Adjust the logic around the message length check and
`${message:0:4096}` slicing to truncate by UTF-16 units or use a conservative
lower limit that leaves sufficient headroom for supplementary characters and
emoji.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a8476382-843f-4348-b485-46b6885e0eb3

📥 Commits

Reviewing files that changed from the base of the PR and between 3aac789 and 66322ce.

📒 Files selected for processing (1)
  • .github/workflows/telegram-release.yml

Comment thread .github/workflows/telegram-release.yml
Comment thread .github/workflows/telegram-release.yml Outdated
The truncation note picked up the YAML indentation of its continuation
line, so it rendered with leading spaces in the announcement.

Telegram measures messages in UTF-16 units, where emoji cost two, but
Bash counts one. Both the size check and the fallback cut now run on the
UTF-16 encoding, and a cut landing inside a surrogate pair drops the
dangling half rather than emitting an invalid string.
@Jordy-Baby

Jordy-Baby commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@DZakh ready for another look.

Both CodeRabbit threads are fixed and resolved.

The PR has also grown since your approval, so worth a fresh read. It now has a manual trigger that renders an existing tag, so the announcement can be checked without waiting for a real release. It defaults to printing the message to the job log rather than sending, and a real release always sends regardless of the inputs.

The workflow only ran on a published release, so the first proof that a
message renders and sends was the release itself.

Adds a manual trigger that renders an existing tag. It defaults to
printing the message in the job log rather than sending, and a real
release ignores both inputs and always sends.
dry_run defaults to true for manual runs. Keying the skip on the input
alone left a real release one context quirk away from going quiet, so it
now also requires the manual event.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/telegram-release.yml (1)

105-115: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Prevent code corruption inside fenced code blocks.

The sed pipeline at the end of the markdown conversion replaces backticks with <code> and removes ** indiscriminately across the entire text. This corrupts code snippets inside <pre> blocks (e.g., stripping backticks from shell scripts or removing ** from math operations).

Move this formatting logic into awk and apply it only outside of code blocks (inpre == 0) to preserve the integrity of the code snippets.

🛠️ Proposed fix
-          # shellcheck disable=SC2016  # $0 below is awk's field var, not a shell expansion
-          notes="$(printf '%s\n' "$body" | esc | awk '
-            BEGIN { inpre = 0 }
-            /^```/ { if (inpre) { print "</pre>"; inpre = 0 } else { print "<pre>"; inpre = 1 } next }
-            inpre == 0 && /^[[:space:]]*#{1,6}[[:space:]]+/ {
-              sub(/^[[:space:]]*#+[[:space:]]+/, ""); print "<b>" $0 "</b>"; next
-            }
-            { print }
-            END { if (inpre) print "</pre>" }
-          ' | sed -E 's/`([^`]+)`/<code>\1<\/code>/g; s/\*\*//g')"
+          # shellcheck disable=SC2016  # $0 below is awk's field var, not a shell expansion
+          notes="$(printf '%s\n' "$body" | esc | awk '
+            BEGIN { inpre = 0 }
+            /^```/ { if (inpre) { print "</pre>"; inpre = 0 } else { print "<pre>"; inpre = 1 } next }
+            inpre == 0 {
+              head = ""
+              tail = $0
+              while (match(tail, /`[^`]+`/)) {
+                head = head substr(tail, 1, RSTART - 1) "<code>" substr(tail, RSTART + 1, RLENGTH - 2) "</code>"
+                tail = substr(tail, RSTART + RLENGTH)
+              }
+              $0 = head tail
+              gsub(/\*\*/, "")
+            }
+            inpre == 0 && /^[[:space:]]*#{1,6}[[:space:]]+/ {
+              sub(/^[[:space:]]*#+[[:space:]]+/, ""); print "<b>" $0 "</b>"; next
+            }
+            { print }
+            END { if (inpre) print "</pre>" }
+          ')"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/telegram-release.yml around lines 105 - 115, Update the
markdown conversion awk pipeline to handle inline backticks and remove double
asterisks only when inpre == 0, preserving all content inside fenced <pre>
blocks. Remove the trailing sed formatting stage, while keeping fenced-block
toggling and heading conversion unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/telegram-release.yml:
- Around line 128-132: Update the plain-text fallback in the message-length
check to reserve space for the fixed release title, prompt, and URL, then
truncate only BODY to the remaining UTF-16-safe budget. Reassemble the message
with the complete URL and surrounding text preserved, while keeping parse_mode
empty.

---

Outside diff comments:
In @.github/workflows/telegram-release.yml:
- Around line 105-115: Update the markdown conversion awk pipeline to handle
inline backticks and remove double asterisks only when inpre == 0, preserving
all content inside fenced <pre> blocks. Remove the trailing sed formatting
stage, while keeping fenced-block toggling and heading conversion unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5cc927a1-895c-46d3-a8df-d62ff1c3d9a1

📥 Commits

Reviewing files that changed from the base of the PR and between 66322ce and 6059c00.

📒 Files selected for processing (1)
  • .github/workflows/telegram-release.yml

Comment thread .github/workflows/telegram-release.yml
The fallback assembled the header, notes and link and then cut the whole
thing to the limit. The link sits at the end, so a long enough body cut
it away and left the announcement with no route back to the release.

The notes are now budgeted against the header and link, so the link
survives whatever the notes do.
@Jordy-Baby

Copy link
Copy Markdown
Contributor Author

Friendly reminder on this @DZakh 😄

@DZakh
DZakh enabled auto-merge (squash) July 17, 2026 14:39
@DZakh
DZakh merged commit 497f666 into main Jul 17, 2026
8 checks passed
@DZakh
DZakh deleted the ci/telegram-release-announcements branch July 17, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants