From 3cc811cd8eb2c0f27f239f88d4c7099bb22bf880 Mon Sep 17 00:00:00 2001 From: amos Date: Tue, 2 Jun 2026 23:55:22 +0800 Subject: [PATCH] =?UTF-8?q?debug:=20=E6=B7=BB=E5=8A=A0=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E5=92=8C=E5=A4=9A=20endpoint=20=E5=B0=9D?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/android-release.yml | 69 ++++++++++++++-------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/.gitea/workflows/android-release.yml b/.gitea/workflows/android-release.yml index 75d4978..2604bda 100644 --- a/.gitea/workflows/android-release.yml +++ b/.gitea/workflows/android-release.yml @@ -50,6 +50,12 @@ jobs: echo "APK_FILE=$APK_FILE" >> $GITHUB_ENV echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Debug Network + run: | + echo "Testing network connectivity..." + ping -c 2 gitea.kg8.net || echo "ping failed" + curl -v "https://gitea.kg8.net/api/v1/version" 2>&1 | head -20 || echo "curl failed" + - name: Create Release and Upload APK env: AUTH: ${{ secrets.AUTHB64 }} @@ -59,38 +65,33 @@ jobs: run: | echo "Creating release for ${VERSION}..." - # 删除已存在的 release - EXISTING=$(curl -s -H "Authorization: Basic ${AUTH}" "https://gitea.kg8.net/api/v1/repos/${REPO}/releases/tags/${VERSION}") - RELEASE_ID=$(echo "$EXISTING" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) + # 尝试不同的 API endpoint + for API_URL in "https://gitea.kg8.net/api/v1" "http://localhost:3000/api/v1" "http://127.0.0.1:3000/api/v1"; do + echo "Trying: ${API_URL}" + RESPONSE=$(curl -s -X POST "${API_URL}/repos/${REPO}/releases" \ + -H "Authorization: Basic ${AUTH}" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\":\"${VERSION}\",\"name\":\"Release ${VERSION}\",\"draft\":false,\"prerelease\":false}" \ + --connect-timeout 5) + + echo "Response: ${RESPONSE}" + + RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) + + if [ -n "$RELEASE_ID" ]; then + echo "✅ Release 创建成功 (ID: ${RELEASE_ID}) via ${API_URL}" + + # 上传 APK + echo "Uploading APK: ${APK_FILE}" + UPLOAD_RESPONSE=$(curl -s -X POST "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets" \ + -H "Authorization: Basic ${AUTH}" \ + -F "attachment=@${APK_FILE}") + + echo "Upload Response: ${UPLOAD_RESPONSE}" + echo '✅ APK 上传成功!' + exit 0 + fi + done - if [ -n "$RELEASE_ID" ]; then - echo "删除已存在的 Release (ID: ${RELEASE_ID})" - curl -s -X DELETE -H "Authorization: Basic ${AUTH}" "https://gitea.kg8.net/api/v1/repos/${REPO}/releases/${RELEASE_ID}" - sleep 2 - fi - - # 创建新的 Release - RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/${REPO}/releases" \ - -H "Authorization: Basic ${AUTH}" \ - -H "Content-Type: application/json" \ - -d "{\"tag_name\":\"${VERSION}\",\"name\":\"Release ${VERSION}\",\"draft\":false,\"prerelease\":false}") - - echo "Create Response: ${RESPONSE}" - - RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) - - if [ -z "$RELEASE_ID" ]; then - echo "❌ Failed to create release" - exit 1 - fi - - echo "✅ Release 创建成功 (ID: ${RELEASE_ID})" - - # 上传 APK - echo "Uploading APK: ${APK_FILE}" - UPLOAD_RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \ - -H "Authorization: Basic ${AUTH}" \ - -F "attachment=@${APK_FILE}") - - echo "Upload Response: ${UPLOAD_RESPONSE}" - echo '✅ APK 上传成功!' \ No newline at end of file + echo "❌ Failed to create release on all endpoints" + exit 1 \ No newline at end of file