diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70db180..2782d44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,7 +147,7 @@ jobs: echo "ver=$ver" >> "$GITHUB_OUTPUT" if [ "$prev" != "Cerberus $ver" ]; then echo "new=true" >> "$GITHUB_OUTPUT" - echo "announce=true" >> "$GITHUB_OUTPUT" # a new version: Telegram (#34) + echo "announce=true" >> "$GITHUB_OUTPUT" # a new version: binaries to Telegram (#40) else # same version: publish again only if a publication was cut off and files are missing have=$(gh release view latest --repo "$GITHUB_REPOSITORY" --json assets -q '.assets[].name') @@ -205,8 +205,10 @@ jobs: --target "$GITHUB_SHA" --title "Cerberus ${VER}" --notes-file notes.md fi - # A new version (not a re-publication of the same one) goes to the OpenIPC Telegram dev - # channel (#34). Organization secrets; a failed post is a warning, not a failed release. + # The binaries of a new version (not a re-publication of the same one) go to the OpenIPC + # Telegram dev channel as files, for the archive and test downloads: one post + # (sendMediaGroup), a short caption, no text from CHANGELOG.md (#40). Organization secrets; + # a failed upload is a warning, not a failed release. - name: Telegram if: steps.ver.outputs.announce == 'true' env: @@ -215,19 +217,19 @@ jobs: VER: ${{ steps.ver.outputs.ver }} run: | if [ -z "$TG_TOKEN" ] || [ -z "$TG_CHANNEL" ]; then - echo "::warning::Telegram secrets are not available, version not announced"; exit 0 + echo "::warning::Telegram secrets are not available, binaries not posted"; exit 0 fi - url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" - # the CHANGELOG.md section of this version, without its heading - # (one awk, no pipe: under pipefail a head closing the pipe early would fail the step) - changes=$(awk -v h="## ${VER} — " 'index($0, h) == 1 {f = 1; next} /^## / && f {exit} - f && (s || $0 != "") {s = 1; if (++n > 15) exit; print}' CHANGELOG.md) - # Telegram takes 4096 characters per message: keep the excerpt well below that - [ "${#changes}" -le 3000 ] || changes="${changes:0:3000}…" - text=$(printf 'Cerberus %s\nCommit: %s\nTime: %s\n\n%s\n\nInstall: curl -fsSL %s/releases/latest/download/install.sh | sh -s -- \n%s/releases/latest' \ - "$VER" "${GITHUB_SHA::7}" "$(date -u '+%Y-%m-%d %H:%M:%S UTC')" "$changes" "$url" "$url") - HTTP=$(curl -sS -o tg.json -w '%{http_code}' "https://api.telegram.org/bot${TG_TOKEN}/sendMessage" \ - --data-urlencode "chat_id=${TG_CHANNEL}" --data-urlencode "text=${text}" \ - --data "disable_web_page_preview=true") || HTTP=000 + caption=$(printf 'Cerberus %s for Linux\nCommit: %s\nTime: %s\n\n%s' "$VER" "${GITHUB_SHA::7}" \ + "$(date -u '+%Y-%m-%d %H:%M:%S UTC')" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/latest") + files=(dist/cerberus-*) + media='[]' form=() + for i in "${!files[@]}"; do + item=$(jq -cn --arg m "attach://f$i" '{type: "document", media: $m}') + [ "$i" -eq $(( ${#files[@]} - 1 )) ] && item=$(jq -c --arg c "$caption" '. + {caption: $c}' <<< "$item") + media=$(jq -c --argjson it "$item" '. + [$it]' <<< "$media") + form+=(-F "f$i=@${files[$i]}") + done + HTTP=$(curl -sS -o tg.json -w '%{http_code}' "https://api.telegram.org/bot${TG_TOKEN}/sendMediaGroup" \ + -F chat_id="$TG_CHANNEL" -F media="$media" "${form[@]}") || HTTP=000 echo "Telegram response: $HTTP" - [ "$HTTP" = 200 ] || echo "::warning::Telegram post failed (HTTP $HTTP)" + [ "$HTTP" = 200 ] || echo "::warning::Telegram upload failed (HTTP $HTTP): $(cat tg.json 2>/dev/null)" diff --git a/README.md b/README.md index f2a76e7..ddc23ad 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ at all: Asset names carry no version on purpose: `releases/latest/download/` always points at the current release. -Every new version is announced in the OpenIPC Telegram channels ([our channels](https://openipc.org/our-channels)). +The binaries of every new version are also posted to the OpenIPC Telegram channel ([our channels](https://openipc.org/our-channels)), for the archive and test downloads. The change history of every version is in [CHANGELOG.md](CHANGELOG.md). diff --git a/README.ru.md b/README.ru.md index f5d54bf..1640f81 100644 --- a/README.ru.md +++ b/README.ru.md @@ -90,7 +90,7 @@ fw_setenv cerberus_enrollment_token tok_... Версии в именах файлов нет специально: `releases/latest/download/<имя>` всегда ведёт на текущий релиз. -О каждой новой версии сообщается в Telegram-каналах OpenIPC ([наши каналы](https://openipc.org/our-channels)). +Бинарники каждой новой версии также выкладываются в Telegram-канал OpenIPC ([наши каналы](https://openipc.org/our-channels)) — для архива и тестовых скачиваний. История изменений по версиям — в [CHANGELOG.md](CHANGELOG.md). diff --git a/README.zh-CN.md b/README.zh-CN.md index 131173f..3fbaaf6 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -82,7 +82,7 @@ fw_setenv cerberus_enrollment_token tok_... 文件名中故意不带版本号:`releases/latest/download/<文件名>` 始终指向最新发布。 -每个新版本都会在 OpenIPC 的 Telegram 频道中发布([我们的频道](https://openipc.org/our-channels))。 +每个新版本的二进制文件也会发布到 OpenIPC 的 Telegram 频道([我们的频道](https://openipc.org/our-channels)),用于存档和测试下载。 各版本的变更记录见 [CHANGELOG.md](CHANGELOG.md)。