Files
ykxmz/_build/final_clean_check.sh
xmz7891 4de2255ee4 加 EzHub(Gitea)发布支持 + 一次发两个平台的脚本
用户要求:除了 Gitee,还要发到朋友自建的代码托管平台 EzHub
(ssh://git@git.261826.xyz/xmz/ykxmz.git),release 也要建。

探测结果:EzHub 是 **Gitea 1.22.0**
(/api/v1/version 返回 16.0.5+gitea-1.22.0),
仓库 xmz/ykxmz 存在,目前还没有任何发行版。

Gitea 和 Gitee 的接口差别(踩过的点):
  项目           Gitee                  Gitea / EzHub
  API 前缀       /api/v5/repos/...      /api/v1/repos/...
  认证           参数 access_token      请求头 Authorization: token
  传附件路径     /releases/{id}/        /releases/{id}/
                 attach_files           assets?name=<文件名>
  附件字段名     file                   attachment
  草稿字段       无                     draft / prerelease

新增:
  * _build/ezhub_release.py   单独发 EzHub 用
  * _build/release_all.py     一次发两个平台(推荐)
      - 前置检查:产物齐不齐、更新说明能不能取到、工作区干不干净
      - **对外口径检查**:更新说明里出现管理页字眼直接拒绝发布
      - 推代码到两个 remote,再分别在两边建发行版 + 传三个附件
      - 支持 --dry 演练(不真的发),已经过通

修掉的 bug:
  CHANGELOG 解析。按 "\n## " 切分时第一块带着自己的 "## 版本号"
  (前面没换行),后面几块没有 —— 原来只写 startswith("1.8.0"),
  对第一块永远匹配不上,全靠"取不到就退回第一块"的兜底碰巧对了。
  现在先把开头的 # 去掉再比。

SSH:
  为 EzHub 单独生成了一把密钥(~/.ssh/id_ed25519_ezhub),
  不复用 Gitee 那把,权限隔离。已写好 ~/.ssh/config 的 Host 段。
  **公钥需要用户加到 EzHub 账号里之后才能推。**
  私钥在仓库外,不会进版本库。
2026-10-07 12:19:58 +08:00

76 lines
3.1 KiB
Bash

#!/bin/bash
# 确认线上公开页面干净 + 产物完整
set -u
BASE=https://relay.xxmxxs.top
UA='LanRemote/1.8.0'
echo "════════ 1. 线上官网有没有管理后台字样 ════════"
curl -s --max-time 25 -H "User-Agent: $UA" "$BASE/" -o /tmp/site.html
echo " 官网 $(wc -c < /tmp/site.html) 字节"
hits=0
for kw in zhongzhuanzhan "/admin" 管理后台 管理页 管理入口 admin_password; do
n=$(grep -c "$kw" /tmp/site.html 2>/dev/null || echo 0)
if [ "$n" -gt 0 ]; then
echo " **命中 $kw x$n**"
hits=$((hits + 1))
fi
done
[ "$hits" = "0" ] && echo " ✓ 六个关键词一个都没有"
echo
echo " 官网里的所有站内链接:"
grep -o 'href="/[^"]*"' /tmp/site.html | sort -u | sed 's/^/ /'
echo
echo "════════ 2. 三个产物在不在 ════════"
for f in ykxmz-setup-1.8.0.exe ykxmz-server-1.8.0.zip ykxmz-watch-1.8.0.apk; do
hdr=$(curl -sI --max-time 30 -H "User-Agent: $UA" "$BASE/download/$f")
code=$(echo "$hdr" | head -1 | awk '{print $2}')
len=$(echo "$hdr" | grep -i '^content-length' | tr -d '\r' | awk '{print $2}')
printf " %-30s HTTP %-4s %s 字节\n" "$f" "$code" "${len:-?}"
done
echo
echo "════════ 3. 服务端 zip 里有没有 CHANGELOG(不该有)════════"
python3 - <<'PY'
import zipfile, urllib.request
url = "https://relay.xxmxxs.top/download/ykxmz-server-1.8.0.zip"
try:
data = urllib.request.urlopen(url, timeout=60).read()
import io
with zipfile.ZipFile(io.BytesIO(data)) as z:
names = z.namelist()
print(" 条目 %d 个" % len(names))
bad = [n for n in names
if "CHANGELOG" in n.upper() or "RELEASE" in n.upper()]
print(" %s 没有把更新日志打进包里"
% ("✓" if not bad else "**有 " + str(bad) + "**"))
# 运维文档里提到管理页是允许的
for n in names:
if n.endswith(".txt"):
try:
t = z.read(n).decode("utf-8", "replace")
except Exception:
continue
c = t.count("管理页")
if c:
print(" (运维文档 %s 提到管理页 %d 次 —— 按约定允许)"
% (n.split("/")[-1], c))
except Exception as e:
print(" 取包失败: %s" % e)
PY
echo
echo "════════ 4. 管理页本身还正常吗(不公开提,但得能登录)════════"
PASS=$(cat /root/lanremote-relay/data/admin_password.txt 2>/dev/null)
curl -s -c /tmp/ck.txt -o /dev/null --max-time 20 \
-d "username=xmz7891&password=$PASS" "$BASE/admin/login"
echo " 登录后访问: HTTP $(curl -s -o /dev/null -w '%{http_code}' -b /tmp/ck.txt --max-time 20 -H "User-Agent: $UA" "$BASE/zhongzhuanzhan")"
echo " 未登录: HTTP $(curl -s -o /dev/null -w '%{http_code}' --max-time 20 -H "User-Agent: $UA" "$BASE/zhongzhuanzhan")"
echo
echo "════════ 5. 中转版本 ════════"
curl -s --max-time 15 "$BASE/v1/health" | head -c 150
echo