ci: announce releases to Telegram - #1398
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughA 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. ChangesTelegram release announcements
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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
.github/workflows/telegram-release.yml
3842005 to
3aac789
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
.github/workflows/telegram-release.yml
|
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).
73c300b to
66322ce
Compare
|
@DZakh done 🫡 |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
.github/workflows/telegram-release.yml
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.
|
@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.
There was a problem hiding this comment.
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 winPrevent code corruption inside fenced code blocks.
The
sedpipeline 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
awkand 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
📒 Files selected for processing (1)
.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.
|
Friendly reminder on this @DZakh 😄 |
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.discord-release.yml: skips patch releases and prereleases (alpha/rc)TELEGRAM_RELEASE_BOT_TOKEN,TELEGRAM_RELEASE_CHAT_ID(optionalTELEGRAM_RELEASE_TOPIC_IDfor a forum topic)Validated against all 206 historical releases: 38 would post, matching the Discord workflow.
Summary by CodeRabbit
X.Y.0(with an optional leadingvremoved); others are skipped.