diff --git a/release_fixed.sh b/release_fixed.sh index 5c99a93..c590cd6 100755 --- a/release_fixed.sh +++ b/release_fixed.sh @@ -170,21 +170,86 @@ echo "$RELEASE_NOTES" > release_notes_v${VERSION}.md echo "" echo "🌐 6. 尝试创建 Gitea Release..." +# 自动解析远程URL +remote_url=$(git config --get remote.origin.url) +echo " 远程URL: $remote_url" + +if [[ "$remote_url" =~ ^https://([^/]+)/gitea/([^/]+)/(.+)\.git$ ]]; then + # HTTPS格式:https://biboer.cn/gitea/gavin/iBook.git + GITEA_HOST="${BASH_REMATCH[1]}" + GITEA_USER="${BASH_REMATCH[2]}" + GITEA_REPO_NAME="${BASH_REMATCH[3]}" + API_URL="https://${GITEA_HOST}/gitea/api/v1/repos/${GITEA_USER}/${GITEA_REPO_NAME}/releases" + echo " 解析结果: Host=$GITEA_HOST, User=$GITEA_USER, Repo=$GITEA_REPO_NAME" +elif [[ "$remote_url" =~ ^ssh://git@([^:]+):([^/]+)/([^/]+)/(.+)\.git$ ]]; then + # SSH格式特殊端口 + GITEA_HOST="${BASH_REMATCH[1]}" + GITEA_USER="${BASH_REMATCH[3]}" + GITEA_REPO_NAME="${BASH_REMATCH[4]}" + API_URL="https://${GITEA_HOST}/gitea/api/v1/repos/${GITEA_USER}/${GITEA_REPO_NAME}/releases" + echo " 解析结果: Host=$GITEA_HOST, User=$GITEA_USER, Repo=$GITEA_REPO_NAME" +else + echo " ❌ 无法解析远程URL格式: $remote_url" + echo " 支持的格式:" + echo " - HTTPS: https://host/gitea/user/repo.git" + echo " - SSH: ssh://git@host:port/user/repo.git" + API_URL="" +fi + # 检查是否有 Gitea API Token -if [ -n "$GITEA_TOKEN" ]; then +if [ -n "$GITEA_TOKEN" ] && [ -n "$API_URL" ]; then echo " 发现 API Token,尝试自动创建 Release..." - curl -X POST \ + # 使用简化的英文描述避免编码问题 + SIMPLE_BODY="## iBooks Notes Expert v${VERSION} + +**Release Date**: $(date '+%Y-%m-%d') +**Codename**: CFI Sorting & Optimization + +### Key Features +- ✅ EPUB CFI Sorting: Implemented IDPF standard for accurate note positioning +- ✅ Reading Statistics: Fixed 7-day/30-day/yearly statistics calculation +- ✅ UI Improvements: Cleaned CSS warnings and enhanced button interactions +- ✅ Test Coverage: Comprehensive CFI parsing, sorting, and export validation + +### Technical Details +- New Module: epub_cfi_parser.py - Dedicated CFI parsing engine +- Data Structure: Optimized from nested dict to CFI-sorted list +- Backward Compatible: Smooth upgrade without breaking existing features + +### Verification Data +- Books Processed: 660+ books metadata normal +- Notes Sorted: 232 notes correctly sorted by CFI position +- Reading Stats: 7-day 70min, 30-day 159min, yearly 12313min + +For detailed Chinese release notes, see release.md in repository." + + response=$(curl -s -w "\\nHTTP_CODE:%{http_code}" \ + -X POST \ -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/json" \ - "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases" \ + "$API_URL" \ -d "{ \"tag_name\": \"${TAG_NAME}\", \"name\": \"${RELEASE_NAME}\", - \"body\": $(echo "$RELEASE_NOTES" | jq -Rs .), + \"body\": $(echo "$SIMPLE_BODY" | jq -Rs .), \"draft\": false, \"prerelease\": false - }" && echo " ✅ Release 创建成功!" || echo " ❌ Release 创建失败" + }") + + http_code=$(echo "$response" | grep "HTTP_CODE:" | cut -d: -f2) + response_body=$(echo "$response" | sed '/HTTP_CODE:/d') + + if [ "$http_code" = "201" ]; then + echo " ✅ Release 创建成功!" + echo " 🔗 访问: https://${GITEA_HOST}/gitea/${GITEA_USER}/${GITEA_REPO_NAME}/releases/tag/${TAG_NAME}" + else + echo " ❌ Release 创建失败 (HTTP $http_code)" + echo " 响应: $response_body" + if echo "$response_body" | grep -qi "collation\|utf8"; then + echo " 💡 提示: 检测到字符编码问题,这是服务器端问题" + fi + fi else echo " ⚠️ 未设置 GITEA_TOKEN 环境变量" echo " 📋 请手动在 Gitea 中创建 Release:"