feat(server): 自动更新 /version 清单端点(镜像 jiu)

GET /version(公开)读 /etc/pangolin/version.yaml(每请求重载,免重启);缺省回退。
download_urls 接 /downloads。deploy.sh 装清单(存在则不覆盖, 保住线上 bump)。含 4 测试。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
This commit is contained in:
wangjia
2026-07-07 00:12:46 +08:00
parent ec0942e1e7
commit 4baf24f6f8
5 changed files with 336 additions and 0 deletions
+10
View File
@@ -178,6 +178,7 @@ GRPC_KEY_PATH=$ETC/grpc.key
PANGOLIN_PUBLIC_URL=https://api.yanmeiai.com
PANGOLIN_RULES_DIR=$DATA_DIR/rules
DOWNLOADS_DIR=$DATA_DIR/downloads
VERSION_MANIFEST=$ETC/version.yaml
EOF
if [ -n "${SMTP_HOST:-}" ]; then
cat >> "$ETC/server.env" <<EOF
@@ -211,6 +212,15 @@ curl -fsSL -o "$RULES_DIR/geosite-cn.srs" \
DOWNLOADS_DIR="$DATA_DIR/downloads"
install -d -m 755 "$DOWNLOADS_DIR"
# ── 6d. 客户端自动更新版本清单 ─────────────────────────────────────────────────
# GET /version(公开、免鉴权)按 VERSION_MANIFEST(见上 server.env)读取该文件;
# scripts/ci/release-client.sh 每次 client-v* 发版都会以本仓库这份文件为模板,
# 改写 version/build_number 后 SSH 推到这个路径覆盖 —— 幂等重跑本脚本不应该把
# 已发布的最新版本号退回仓库里的默认值,所以文件已存在时不覆盖。
if [ ! -f "$ETC/version.yaml" ]; then
install -m 644 "$HERE/version.yaml" "$ETC/version.yaml"
fi
# ── 7. 迁移 + seed(SQLite)────────────────────────────────────────────────────
log "执行迁移(sqlite)..."
DB_DRIVER=sqlite DB_DSN="$DB_FILE" "$BIN/pangolin-migrate" up
+22
View File
@@ -0,0 +1,22 @@
# version.yaml — 客户端自动更新版本清单(committed default)。
#
# deploy/single-node/deploy.sh 把这份文件安装到 /etc/pangolin/version.yaml
# (VERSION_MANIFEST 默认路径,见 server/internal/httpapi/version.go)。
# scripts/ci/release-client.sh 在每次 client-v* 发版时,以这份文件为模板改写
# version / build_number 字段,再原样(SSH)推到 pangolin1 的
# /etc/pangolin/version.yaml —— 控制面每次请求都重新读该文件,发版立即生效,
# 不需要重启/重新部署控制面。
#
# download_urls 目前是固定「仅保留最新一份」的稳定 URL(deploy-client.sh 每次
# 用同名文件覆盖),不是按版本变化的路径,因此这里不需要随发版改写;
# macos / ios 产物尚未产出,先留空字符串。
version: "1.0.48"
build_number: 10048
force_update: false
release_notes: ""
download_urls:
android: "https://api.yanmeiai.com/downloads/pangolin-android.apk"
windows: "https://api.yanmeiai.com/downloads/pangolin-windows-x64-setup.exe"
macos: ""
ios: ""
changelog: []