chore: 加固 Gitea Release 上传,避免维护期丢资产

0.9.5 的 Release workflow 因 Gitea 服务端维护期不稳,5 个资产
上传 3 次重试全部失败,Gitea 侧只落地 7/12(已手动补齐)。
根因不是代码缺陷,但二进制变大后并发大文件上传放大了影响。

- job timeout-minutes: 30 → 60,给重试留足窗口。
- 单资产重试次数 3 → 5,间隔保持 3 秒。
- 上传从「2 并发 + wait」改为串行,维护期不再互相抢带宽;
  幂等逻辑不变(已存在资产校验 SHA-256 后跳过,字节不同才删除重传)。
- 同步 release-validation.test.ts:断言改 attempt 2/5,
  并发用例改为验证严格单 worker(peak === 1),
  失败用例的 spawnSync 超时放宽到 40s。

校验:YAML parse 通过;bun test 1114 pass / 0 fail;
bun run check、check:readme 37/37 全通过。
本次只改 CI,不打 tag、不发版。
This commit is contained in:
gitea committed 2026-11-06 10:39:49 +08:00
1 parent f3caebfd8a
commit bfbf6cf55f
2 files changed
+11 -19

No files matched your search

+7 -15
View File
@@ -27,7 +27,7 @@ jobs:
build-and-publish:
name: 🚀 Build & Publish Multi-Platform Binaries
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 60
permissions:
contents: write
env:
@@ -183,9 +183,9 @@ jobs:
local file="$1" filename expected_hash attempt info existing remote_hash asset_id response delete_failed
filename=$(basename "$file")
expected_hash=$(sha256sum "$file" | awk '{ print $1 }')
for attempt in 1 2 3; do
for attempt in 1 2 3 4 5; do
if [ "$attempt" -gt 1 ]; then sleep "${GITEA_RETRY_DELAY:-3}"; fi
echo " [start] Uploading ${filename} to Gitea (attempt ${attempt}/3)..."
echo " [start] Uploading ${filename} to Gitea (attempt ${attempt}/5)..."
if ! info=$(curl -fsS --connect-timeout 15 --max-time 60 -H "Authorization: token ${GITEA_TOKEN}" "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}"); then
continue
fi
@@ -212,24 +212,16 @@ jobs:
return 0
fi
done
echo "::error::Failed to upload ${filename} after 3 attempts."
echo "::error::Failed to upload ${filename} after 5 attempts."
return 1
}
# Bound outbound traffic: large raw binaries must not compete with all archives.
pids=()
# 串行上传:Gitea 维护期并发推大文件容易把重试窗口耗光,宁可慢也不要丢资产。
# 配合 job 超时 60 分钟与单资产 5 次重试,给服务端抖动留出余量。
failed=0
for file in dist/bin/hose-use-* dist/bin/checksums.txt; do
upload_asset "$file" &
pids+=($!)
if [ "${#pids[@]}" -eq 2 ]; then
for pid in "${pids[@]}"; do wait "$pid" || failed=1; done
pids=()
fi
upload_asset "$file" || failed=1
done
if [ "${#pids[@]}" -gt 0 ]; then
for pid in "${pids[@]}"; do wait "$pid" || failed=1; done
fi
if [ "$failed" -ne 0 ]; then
echo "::error::One or more Gitea assets failed to upload."
exit 1