From c8eabe0596a5ffff276869c29f1ab106d9b3a2fc Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Sat, 18 Jul 2026 09:13:50 +0800 Subject: [PATCH] =?UTF-8?q?ci(windows):=20Windows=20=E5=8C=85=E5=8F=91?= =?UTF-8?q?=E7=89=88=E6=94=B9=E4=BB=8E=20GitHub=20Release=20=E6=8B=89?= =?UTF-8?q?=E5=8F=96(=E5=85=8D=20frps)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mac-runner off-LAN 时,从 NAS 经 ali frps 下载 26MB 太慢/易断(实测 ~220KB/s 且中途断)。 改为:windows.yml 额外发布到 GitHub Release winstage-v<版本>;deploy-client 的 build-windows-ci 从 github.com 拉(不过 frps)+ 重试断点续传 + 完整性校验。 需 gitea 密钥 GH_TOKEN(已设)。NAS 暂存保留作记录。 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01P9G7E3wmAYL9KeYCVZVsqu --- .gitea/workflows/deploy-client.yml | 9 +++--- .github/workflows/windows.yml | 13 ++++++++ scripts/ci/fetch-windows-staged.sh | 51 +++++++++++++++++------------- 3 files changed, 46 insertions(+), 27 deletions(-) diff --git a/.gitea/workflows/deploy-client.yml b/.gitea/workflows/deploy-client.yml index d7a1610..55a828a 100644 --- a/.gitea/workflows/deploy-client.yml +++ b/.gitea/workflows/deploy-client.yml @@ -149,7 +149,7 @@ jobs: name: windows path: dist/ - # 特殊:家里 Windows 关机/连不上时,从 NAS 暂存拉 GitHub 云构建的安装器(版本强匹配)。 + # 特殊:家里 Windows 关机/连不上时,从 GitHub Release 拉云构建的安装器(版本强匹配,免 frps)。 # 启用:gitea 仓库设变量 WINDOWS_SOURCE=github,并先在 GitHub 跑 windows.yml 构建该版本。 # 产出同名 windows artifact,下游 release-deploy-client 无需改动。 build-windows-ci: @@ -158,11 +158,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Fetch staged Windows installer from NAS + - name: Fetch staged Windows installer from GitHub (免 frps) env: - FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} - FORGEJO_URL: ${{ secrets.FORGEJO_URL }} - GITEA_REPOSITORY: ${{ gitea.repository }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + GH_REPO: bj-wangjia/jiu run: sh scripts/ci/fetch-windows-staged.sh "${{ gitea.ref_name }}" - name: Upload windows artifacts diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 0d12029..56e3db3 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -64,6 +64,19 @@ jobs: path: dist/jiu-windows-x64-setup.exe if-no-files-found: error + # 发布到 GitHub Release winstage-v<版本> —— 发版时 mac-runner 从这里(github.com)拉, + # 不走 ali frps(off-LAN 时 NAS 经 frps 太慢/易断)。用内置 GITHUB_TOKEN,免额外密钥。 + - name: Publish installer → GitHub Release (winstage-v<版本>,供 mac-runner 免 frps 拉取) + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + tag="winstage-v${{ steps.ver.outputs.ver }}" + gh release delete "$tag" -R "${{ github.repository }}" --yes --cleanup-tag 2>/dev/null || true + gh release create "$tag" -R "${{ github.repository }}" \ + --title "$tag" --notes "Windows 安装器暂存(供 deploy-client 免 frps 拉取)" \ + dist/jiu-windows-x64-setup.exe + - name: Stage installer → NAS gitea (winstage-v<版本>) shell: bash env: diff --git a/scripts/ci/fetch-windows-staged.sh b/scripts/ci/fetch-windows-staged.sh index 5344258..e7b4ae9 100755 --- a/scripts/ci/fetch-windows-staged.sh +++ b/scripts/ci/fetch-windows-staged.sh @@ -1,53 +1,60 @@ #!/usr/bin/env bash -# fetch-windows-staged.sh — 发版时从 NAS gitea 暂存 Release 拉 Windows 安装器。 +# fetch-windows-staged.sh — 发版时从 GitHub Release 拉 Windows 安装器。 # # 用途:deploy-client.yml 的 build-windows-ci job(仅当 WINDOWS_SOURCE=github 时启用) -# 调用此脚本,按发版 tag(client-vX.Y.Z) 的**同一版本号**去找 `winstage-vX.Y.Z`, +# 调用此脚本,按发版 tag(client-vX.Y.Z) 的**同一版本号**去 GitHub 找 `winstage-vX.Y.Z`, # 把 jiu-windows-x64-setup.exe 下到 dist/,供后续 upload-artifact → release/deploy 使用。 # -# **版本强匹配**:找不到对应版本的暂存包 → 硬失败并提示先在 GitHub 构建该版本, +# **为什么从 GitHub 而不是 NAS**:mac-runner 常在 off-LAN,NAS 只能经 ali frps(慢又易断); +# Windows 包本就是 GitHub 云构建的,直接从 github.com 拉最稳、不过 frps。 +# +# **版本强匹配**:找不到对应版本的 GitHub Release → 硬失败并提示先构建该版本, # 绝不静默发出旧版/错版 Windows 包。 # -# 需要 env:FORGEJO_URL、FORGEJO_TOKEN、GITEA_REPOSITORY。 +# 需要 env:GH_TOKEN(github PAT,私有库拉 release 需 auth);GH_REPO(默认 bj-wangjia/jiu)。 set -euo pipefail -. "$(dirname "$0")/lib-forgejo.sh" - TAG="$1" -VER="$(ver_from_tag "$TAG")" +VER="${TAG#client-v}"; VER="${VER#v}" STAGE_TAG="winstage-v${VER}" NAME="jiu-windows-x64-setup.exe" +GH_REPO="${GH_REPO:-bj-wangjia/jiu}" +: "${GH_TOKEN:?需要 GH_TOKEN(github PAT)}" -echo "==> fetch-windows-staged: 发版版本=${VER},找暂存 ${STAGE_TAG}" -base="${FORGEJO_URL}/api/v1/repos/${GITEA_REPOSITORY}" +echo "==> fetch-windows-staged: 发版版本=${VER},从 GitHub 找 ${STAGE_TAG}(repo ${GH_REPO})" +api="https://api.github.com/repos/${GH_REPO}" mkdir -p dist -if ! info=$(curl -kfsS -H "Authorization: token ${FORGEJO_TOKEN}" "${base}/releases/tags/${STAGE_TAG}" 2>/dev/null); then +if ! info=$(curl -fsSL -H "Authorization: Bearer ${GH_TOKEN}" -H "Accept: application/vnd.github+json" "${api}/releases/tags/${STAGE_TAG}" 2>/dev/null); then cat >&2 <&2 exit 1 fi -echo "==> fetch-windows-staged: 下载 ${dl} → dist/${NAME}" -curl -kfsSL -H "Authorization: token ${FORGEJO_TOKEN}" "$dl" -o "dist/${NAME}" +echo "==> fetch-windows-staged: 下载 asset id=${aid}(GitHub)→ dist/${NAME}" +# 重试 + 断点续传(-C -)+ 低速/超时上限:断了自动续传重来,不会一次瞬断就整个失败。 +curl -fSL \ + --retry 30 --retry-delay 5 --retry-all-errors -C - \ + --connect-timeout 15 --speed-time 60 --speed-limit 1024 --max-time 900 \ + -H "Authorization: Bearer ${GH_TOKEN}" -H "Accept: application/octet-stream" \ + "${api}/releases/assets/${aid}" -o "dist/${NAME}" ls -lh "dist/${NAME}" + # 完整性校验:安装器至少应有 1MB,防重定向页/截断被当成有效包发出去。 sz=$(wc -c < "dist/${NAME}") if [ "$sz" -lt 1000000 ]; then - echo "ERROR: 下载的 ${NAME} 仅 ${sz} 字节,疑似重定向页/损坏,拒绝发版。" >&2 + echo "ERROR: 下载的 ${NAME} 仅 ${sz} 字节,疑似损坏,拒绝发版。" >&2 exit 1 fi -echo "==> fetch-windows-staged: done(版本 ${VER} 匹配)" +echo "==> fetch-windows-staged: done(版本 ${VER} 匹配,源=GitHub)"