update at 2025-10-15 15:49:56

This commit is contained in:
douboer
2025-10-15 15:49:56 +08:00
parent db46387184
commit c7aa550e65

View File

@@ -173,27 +173,11 @@ else
echo "⚠️ 检查 Release 状态失败 (HTTP $check_http_code),但将继续创建..." echo "⚠️ 检查 Release 状态失败 (HTTP $check_http_code),但将继续创建..."
fi fi
# 7.2 使用 jq 生成正确的 JSON
# 使用临时文件避免 shell 变量中的换行符问题
TEMP_BODY_FILE=$(mktemp)
echo "$TAG_MESSAGE" > "$TEMP_BODY_FILE"
JSON_PAYLOAD=$(jq -n -c \ # 7.2 直接用 shell 拼接 JSON不用 jq不用临时文件
--arg version "$VERSION" \ JSON_PAYLOAD="{\n \"tag_name\": \"$VERSION\",\n \"name\": \"$VERSION - $RELEASE_TITLE\",\n \"body\": \"$(echo "$TAG_MESSAGE" | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/"/\\"/g')\",\n \"draft\": false,\n \"prerelease\": false\n}"
--arg title "$VERSION - $RELEASE_TITLE" \
--rawfile body "$TEMP_BODY_FILE" \
'{
tag_name: $version,
name: $title,
body: $body,
draft: false,
prerelease: false
}')
# 清理临时文件 echo "🔄 尝试创建 Release (直接拼接 JSON)..."
rm -f "$TEMP_BODY_FILE"
echo "🔄 尝试创建 Release (使用中文内容)..."
response=$(curl -s -w "\n%{http_code}" \ response=$(curl -s -w "\n%{http_code}" \
-X POST "$GITEA_URL/api/v1/repos/$GITEA_REPO/releases" \ -X POST "$GITEA_URL/api/v1/repos/$GITEA_REPO/releases" \
-H "Content-Type: application/json; charset=utf-8" \ -H "Content-Type: application/json; charset=utf-8" \
@@ -209,6 +193,8 @@ if [ "$http_code" -eq 201 ]; then
echo "🔗 Release 地址: $release_url" echo "🔗 Release 地址: $release_url"
elif [[ "$response_body" == *"Conversion from collation"* ]] || [[ "$response_body" == *"utf8"* ]]; then elif [[ "$response_body" == *"Conversion from collation"* ]] || [[ "$response_body" == *"utf8"* ]]; then
echo "⚠️ 检测到字符集问题,尝试使用英文版本..." echo "⚠️ 检测到字符集问题,尝试使用英文版本..."
echo "🐛 调试信息 - HTTP Code: $http_code"
echo "🐛 调试信息 - Response Body: $response_body"
# 创建简化的英文版本 # 创建简化的英文版本
ENGLISH_BODY="## Release Notes\n\nThis is release $VERSION: $RELEASE_TITLE\n\nFor detailed Chinese release notes, please see:\n- release.md in the repository\n- Or visit: $GITEA_URL/$GITEA_REPO/src/branch/main/release.md\n\n### Quick Start\n\n\`\`\`bash\ngit pull origin main\ncd web && npm install\nnpm run dev\n\`\`\`" ENGLISH_BODY="## Release Notes\n\nThis is release $VERSION: $RELEASE_TITLE\n\nFor detailed Chinese release notes, please see:\n- release.md in the repository\n- Or visit: $GITEA_URL/$GITEA_REPO/src/branch/main/release.md\n\n### Quick Start\n\n\`\`\`bash\ngit pull origin main\ncd web && npm install\nnpm run dev\n\`\`\`"