Files
jiu/scripts/ci/fetch-windows-staged.sh
T
wangjia 0a54ded445 ci(windows): GitHub 云构建 Windows 安装器暂存 NAS + 发版可选来源(home/github)
家里 Windows runner 关机时的备用构建源。
- windows.yml: 构建 Inno 安装器(复用 compile-windows.sh)→ 暂存 NAS gitea winstage-v<版本>
- deploy-client.yml: build-windows 加 home/github 开关(参数 windows_source 优先,变量 WINDOWS_SOURCE 兜底),新增 build-windows-ci 从 NAS 按版本拉取
- stage/fetch 脚本: 版本强匹配,拉不到硬失败

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9G7E3wmAYL9KeYCVZVsqu
2026-07-18 07:08:48 +08:00

49 lines
2.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# fetch-windows-staged.sh <tag> — 发版时从 NAS gitea 暂存 Release 拉 Windows 安装器。
#
# 用途:deploy-client.yml 的 build-windows-ci job(仅当 WINDOWS_SOURCE=github 时启用)
# 调用此脚本,按发版 tag(client-vX.Y.Z) 的**同一版本号**去找 `winstage-vX.Y.Z`
# 把 jiu-windows-x64-setup.exe 下到 dist/,供后续 upload-artifact → release/deploy 使用。
#
# **版本强匹配**:找不到对应版本的暂存包 → 硬失败并提示先在 GitHub 构建该版本,
# 绝不静默发出旧版/错版 Windows 包。
#
# 需要 envFORGEJO_URL、FORGEJO_TOKEN、GITEA_REPOSITORY。
set -euo pipefail
. "$(dirname "$0")/lib-forgejo.sh"
TAG="$1"
VER="$(ver_from_tag "$TAG")"
STAGE_TAG="winstage-v${VER}"
NAME="jiu-windows-x64-setup.exe"
echo "==> fetch-windows-staged: 发版版本=${VER},找暂存 ${STAGE_TAG}"
base="${FORGEJO_URL}/api/v1/repos/${GITEA_REPOSITORY}"
mkdir -p dist
if ! info=$(curl -kfsS -H "Authorization: token ${FORGEJO_TOKEN}" "${base}/releases/tags/${STAGE_TAG}" 2>/dev/null); then
cat >&2 <<MSG
ERROR: NAS 上找不到暂存 Release ${STAGE_TAG}。
WINDOWS_SOURCE=github 需要先在 GitHub 构建**版本 ${VER}** 的 Windows 包:
gh workflow run windows.yml -f ver=${VER} (仓库 bj-wangjia/jiu)
构建完成会把安装器暂存到 NAS,再重跑本次发版即可。
MSG
exit 1
fi
# 找到同名资产 id 并下载(版本已由 STAGE_TAG 精确锁定)。JSON 经 stdin 传入避免转义问题。
aid=$(printf '%s' "$info" | python3 -c "import sys,json; print(next((a['id'] for a in json.load(sys.stdin).get('assets',[]) if a['name']=='${NAME}'), ''))")
rid=$(printf '%s' "$info" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
if [ -z "$aid" ]; then
echo "ERROR: ${STAGE_TAG} 存在但缺少 ${NAME} 资产(GitHub 构建可能失败)。" >&2
exit 1
fi
echo "==> fetch-windows-staged: 下载 asset id=${aid} → dist/${NAME}"
curl -kfsS -H "Authorization: token ${FORGEJO_TOKEN}" \
"${base}/releases/${rid}/assets/${aid}" -o "dist/${NAME}"
ls -lh "dist/${NAME}"
echo "==> fetch-windows-staged: done(版本 ${VER} 匹配)"