v1.5.0 #12

Merged
timi merged 7 commits from dev into master 2026-11-17 15:57:16 +00:00
Showing only changes of commit 9f7f260f3e - Show all commits
+71
View File
@@ -285,6 +285,77 @@ jobs:
-H "Token: $API_TOKEN"
echo "OK: 已发布到 stable"
# 打 tag 的时机是「上线成功」而不是「PR 合并」:草稿发布和失败发布都不该留下版本标记。
# Gitea 建 release 会顺带创建 tag,所以不需要单独 git push refs/tags。
- name: Tag release
if: ${{ steps.version.outputs.publish == 'true' }}
env:
GITEA_TOKEN: ${{ secrets.RUNNER_TOKEN }}
GITEA_SERVER_URL: ${{ github.server_url }}
GITEA_INTERNAL_URL: ${{ vars.TIMI_GITEA_INTERNAL_URL }}
GITEA_REPOSITORY: ${{ github.repository }}
VERSION: ${{ steps.version.outputs.version }}
TARGET: ${{ github.sha }}
NOTE_FILE: release-note.txt
MAX_RETRIES: 3
RETRY_DELAY: 10
run: |
if [ -z "$GITEA_TOKEN" ]; then
echo "FAIL: 缺少 secrets.RUNNER_TOKEN,无法创建 tag"
exit 1
fi
if [ -n "$GITEA_INTERNAL_URL" ]; then
api_base_url="$GITEA_INTERNAL_URL"
else
api_base_url="$GITEA_SERVER_URL"
fi
api_url="$api_base_url/api/v1/repos/$GITEA_REPOSITORY/releases"
# 用 node 拼 payload:release note 是多行 markdown,手拼 JSON 会炸
payload=$(node -e "
const fs = require('fs');
const file = process.env.NOTE_FILE;
const note = file && fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
process.stdout.write(JSON.stringify({
tag_name: 'v' + process.env.VERSION,
name: 'v' + process.env.VERSION,
target_commitish: process.env.TARGET,
draft: false,
prerelease: false,
body: note
}));
")
attempt=1
while [ $attempt -le $MAX_RETRIES ]; do
echo "[Create release] 第 $attempt/$MAX_RETRIES 次"
http_code=$(curl -sS -o /tmp/release.json -w "%{http_code}" -X POST "$api_url" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
--connect-timeout 30 \
--max-time 60 \
-d "$payload" 2>/dev/null) || http_code="000"
echo "HTTP Status: $http_code"
# 409 表示 tag 与 release 已存在(重跑流水线时的正常情况)
if [ "$http_code" = "201" ] || [ "$http_code" = "409" ]; then
echo "OK: v$VERSION 的 tag 与 release 已就绪"
head -c 400 /tmp/release.json
echo
exit 0
fi
if [ $attempt -lt $MAX_RETRIES ]; then
echo "重试中,${RETRY_DELAY}s 后继续"
sleep $RETRY_DELAY
fi
attempt=$((attempt + 1))
done
echo "FAIL: 创建 tag / release 失败(接口或 token 权限问题)"
exit 1
- name: Summary
run: |
if [ "${{ steps.version.outputs.publish }}" = "true" ]; then