From 554938f6a882383f844af3a169da2e707e518059 Mon Sep 17 00:00:00 2001 From: professorDeveloper <108933534+professorDeveloper@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:01:57 +0500 Subject: [PATCH] Release: post every published version to the Telegram channel The caption is now the channel post the owner writes by hand: a bold "Sozo X is out!", an italic tagline, a short list, then All files and TV Side links, Discord and Help & Support. The list comes from a hidden block in the notes when there is one, otherwise from the notes' bold titles, one per section in turn, otherwise from the merged changes. Length is measured the way Telegram counts it. A new step posts the banner and this caption to the channel named by the TELEGRAM_CHANNEL variable once the release is published. --- .github/workflows/release.yml | 40 +++++++++- tool/compose_release_notes.py | 113 ++++++++++++++++++++--------- tool/compose_release_notes_test.py | 78 ++++++++++++++------ 3 files changed, 173 insertions(+), 58 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff4e2765..ab1fae64 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1385,12 +1385,19 @@ jobs: SHA: ${{ needs.version.outputs.sha }} TAG: ${{ needs.version.outputs.tag }} NOTES: ${{ inputs.notes }} + MODE: ${{ inputs.release || 'publish' }} + TV_REPO: ${{ vars.TV_REPO || 'professorDeveloper/sozo-tv' }} + GH_TOKEN: ${{ github.token }} run: | set -uo pipefail PREV="$(git tag --merged "${SHA}" --sort=-v:refname --list 'v*' | grep -vx "${TAG}" | head -1 || true)" git log ${PREV:+"${PREV}..${SHA}"} --first-parent --format=%s > changes.txt + # A draft's page is not public yet, so only a published release links to it. + REL="" + if [ "${MODE}" = publish ]; then REL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/tag/${TAG}"; fi + TV="$(gh api "repos/${TV_REPO}/releases/latest" --jq .html_url 2>/dev/null || true)" python3 tool/compose_release_notes.py --version "${V}" --log changes.txt \ - --intro "${NOTES}" --telegram caption.html + --intro "${NOTES}" --telegram caption.html --release-url "${REL}" --tv-url "${TV}" python3 tool/release_banner.py --version "${V}" --still --log changes.txt --out banner.svg # The banner is set in Inter; without it the runner falls back to Liberation Sans. timeout 120 sudo apt-get install -y -qq fonts-inter >/dev/null 2>&1 || true @@ -1544,3 +1551,34 @@ jobs: send_files "${chat}" || { echo "::error::files ${chat}: $(cat /tmp/tg_doc.json)"; fail=1; } done exit "${fail}" + + # The public post: the banner with the caption, nothing else. Only for a + # release that was published, since the post links to its page. + - name: Announce on the channel + if: ${{ always() && (inputs.release || 'publish') == 'publish' && needs.publish.result == 'success' }} + continue-on-error: true + env: + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_CHANNEL_BOT_TOKEN || secrets.TELEGRAM_BOT_TOKEN }} + CHANNEL: ${{ vars.TELEGRAM_CHANNEL }} + run: | + set -uo pipefail + if [ -z "${CHANNEL}" ] || [ -z "${TELEGRAM_BOT_TOKEN}" ]; then + echo "::notice title=Channel post skipped::Set the TELEGRAM_CHANNEL variable (for example @sozoapp) and make the bot an admin of that channel." + exit 0 + fi + if [ ! -s caption.html ]; then + echo "::warning title=Channel post skipped::No caption was built." + exit 0 + fi + API="https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}" + if [ -s banner.png ]; then + curl -sS --fail-with-body -X POST "${API}/sendPhoto" -F "chat_id=${CHANNEL}" \ + -F "photo=@banner.png" -F "caption=