update at 2025-10-15 16:25:19
This commit is contained in:
23
rel.sh
23
rel.sh
@@ -133,7 +133,7 @@ resp_body=$(echo "$response_full" | sed '$d')
|
|||||||
|
|
||||||
if [ "$http_code" -eq 201 ]; then
|
if [ "$http_code" -eq 201 ]; then
|
||||||
echo "✅ Release 创建成功: $VERSION"
|
echo "✅ Release 创建成功: $VERSION"
|
||||||
else
|
else
|
||||||
if [ "$http_code" -eq 409 ]; then
|
if [ "$http_code" -eq 409 ]; then
|
||||||
echo "⚠️ 创建 Release 返回 409 Conflict,尝试删除远程冲突的 Release 并重试..."
|
echo "⚠️ 创建 Release 返回 409 Conflict,尝试删除远程冲突的 Release 并重试..."
|
||||||
# 再次查询 Release id
|
# 再次查询 Release id
|
||||||
@@ -171,10 +171,31 @@ else
|
|||||||
else
|
else
|
||||||
echo "❌ 查询冲突 Release 失败 (HTTP $check_http_code),响应: $check_body"
|
echo "❌ 查询冲突 Release 失败 (HTTP $check_http_code),响应: $check_body"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
# 如果是 500 并且包含 collation/utf8 相关错误,回退到英文 body 重试
|
||||||
|
if [ "$http_code" -eq 500 ] || echo "$resp_body" | grep -qi "collation\|utf8\|Conversion from collation"; then
|
||||||
|
echo "⚠️ 检测到字符集/编码错误 (HTTP $http_code),尝试回退到英文说明并重试..."
|
||||||
|
ENGLISH_BODY="## Release Notes\n\nThis is release $VERSION: $RELEASE_TITLE\n\nFor detailed Chinese release notes, please see release.md in the repository.\n\nQuick start:\n\n\`\`\`bash\ngit pull origin main\ncd web && npm install\nnpm run dev\n\`\`\`"
|
||||||
|
JSON_PAYLOAD_EN=$(jq -n -c --arg version "$VERSION" --arg name "$VERSION" --arg body "$ENGLISH_BODY" '{tag_name: $version, name: $name, body: $body, draft: false, prerelease: false}')
|
||||||
|
echo "🔄 正在创建 Release(英文回退,重试)..."
|
||||||
|
en_resp=$(curl -s -w "\n%{http_code}" \
|
||||||
|
-X POST "$GITEA_URL/api/v1/repos/$GITEA_REPO/releases" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
-d "$JSON_PAYLOAD_EN")
|
||||||
|
en_code=$(echo "$en_resp" | tail -n 1)
|
||||||
|
en_body=$(echo "$en_resp" | sed '$d')
|
||||||
|
if [ "$en_code" -eq 201 ]; then
|
||||||
|
echo "✅ Release 创建成功 (英文回退): $VERSION"
|
||||||
|
else
|
||||||
|
echo "❌ 英文回退重试失败 (HTTP $en_code)"
|
||||||
|
echo "响应: $en_body"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "❌ Release 创建失败,HTTP $http_code"
|
echo "❌ Release 创建失败,HTTP $http_code"
|
||||||
echo "响应: $resp_body"
|
echo "响应: $resp_body"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user