mirror of
https://github.com/Trollobot/Telemax.git
synced 2026-11-16 13:31:17 +00:00
Живые входящие (handleMaxPush) теперь двигают historyBackfillCursor после доставки — раньше только бэкфилл и исходящие двигали его, поэтому catch-up на реконнекте MAX-сессии перечитывал уже доставленные входящие (time > устаревший курсор) и слал их в Telegram повторно. Симметрично уже существующему rememberOutgoingSend для исходящих. Зеркальный latest.json теперь несёт карту changelogs (версия -> заметки); version.ts собирает все версии новее текущей, так что прыжок через несколько версий показывает изменения каждой, а не только последней (как compare-API GitHub).
63 lines
3.2 KiB
Bash
63 lines
3.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Maintainer-only release ritual. Run from a full clone AFTER bumping package.json's version and
|
|
# creating the matching tag (git tag vX.Y.Z). It pushes main + tags to BOTH GitHub (origin) and the
|
|
# self-hosted fallback mirror, then refreshes the mirror's latest.json so installs that CAN'T reach
|
|
# GitHub (account flagged, or GitHub filtered on their network) still learn about the new version
|
|
# and can update from the mirror. See src/bridge/version.ts (checkVersion fallback) and update.sh
|
|
# (git pull fallback) for the consuming side.
|
|
#
|
|
# NOT part of a normal deployment — installs never run this.
|
|
#
|
|
# Usage: ./scripts/release.sh
|
|
# Env: MIRROR_SSH (default root@46.8.238.57)
|
|
# MIRROR_REPO_PATH (default /opt/telemax-mirror/web/Telemax.git)
|
|
# MIRROR_WEB_PATH (default /opt/telemax-mirror/web)
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
TAG="v${VERSION}"
|
|
|
|
MIRROR_SSH="${MIRROR_SSH:-root@46.8.238.57}"
|
|
MIRROR_REPO_PATH="${MIRROR_REPO_PATH:-/opt/telemax-mirror/web/Telemax.git}"
|
|
MIRROR_WEB_PATH="${MIRROR_WEB_PATH:-/opt/telemax-mirror/web}"
|
|
MIRROR_GIT_URL="ssh://${MIRROR_SSH}${MIRROR_REPO_PATH}"
|
|
# Public HTTP base of the mirror — used to read back the current latest.json so the per-version
|
|
# changelog map accumulates across releases (see scripts/build-latest-json.mjs).
|
|
MIRROR_HTTP_URL="${MIRROR_HTTP_URL:-http://zergont-gate.duckdns.org:3200}"
|
|
|
|
echo ">> Releasing ${TAG}"
|
|
|
|
# The tag must already exist (coordinate the tag first, then run this).
|
|
if ! git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
|
|
echo "!! Tag ${TAG} not found. Create it first: git tag ${TAG} then re-run." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo ">> [1/4] push to GitHub (origin)"
|
|
git push origin main
|
|
git push origin "${TAG}"
|
|
|
|
echo ">> [2/4] push to mirror (${MIRROR_GIT_URL})"
|
|
git push "${MIRROR_GIT_URL}" "+refs/heads/main:refs/heads/main" "+refs/tags/*:refs/tags/*"
|
|
|
|
echo ">> [3/4] build latest.json (cumulative per-version changelog)"
|
|
PREV_TAG=$(git describe --tags --abbrev=0 "${TAG}^" 2>/dev/null || echo "")
|
|
RANGE="${TAG}"
|
|
[ -n "${PREV_TAG}" ] && RANGE="${PREV_TAG}..${TAG}"
|
|
# This version's notes: commit subjects since the previous tag, minus the release-bump commit itself.
|
|
NEW_NOTES_JSON=$(git log --format='%s' "${RANGE}" | grep -viE '^Релиз |^Release ' \
|
|
| node -e "const l=require('fs').readFileSync(0,'utf8').split('\n').filter(Boolean); process.stdout.write(JSON.stringify(l))")
|
|
# Accumulate into the map already published on the mirror so multi-version jumps keep every release.
|
|
EXISTING_JSON=$(curl -fsS "${MIRROR_HTTP_URL}/latest.json" 2>/dev/null || echo '{}')
|
|
LATEST_JSON=$(node scripts/build-latest-json.mjs "${VERSION}" "${TAG}" "${NEW_NOTES_JSON}" "${EXISTING_JSON}")
|
|
echo " ${LATEST_JSON}"
|
|
|
|
echo ">> [4/4] upload latest.json + install.sh to mirror + refresh dumb-http index"
|
|
ssh "${MIRROR_SSH}" "cat > ${MIRROR_WEB_PATH}/latest.json" <<<"${LATEST_JSON}"
|
|
# Serve the bootstrap script from the mirror too, so a fresh install works while GitHub is down:
|
|
# curl -fsSL http://<mirror>/install.sh | bash
|
|
scp -q install.sh "${MIRROR_SSH}:${MIRROR_WEB_PATH}/install.sh"
|
|
ssh "${MIRROR_SSH}" "cd ${MIRROR_REPO_PATH} && git update-server-info"
|
|
|
|
echo ">> Done. Released ${TAG} to GitHub + mirror."
|