debug: 添加网络调试和多 endpoint 尝试
Android Release / release (push) Successful in 43s

This commit is contained in:
amos
2026-06-02 23:55:22 +08:00
parent 56298d080f
commit 3cc811cd8e
+35 -34
View File
@@ -50,6 +50,12 @@ jobs:
echo "APK_FILE=$APK_FILE" >> $GITHUB_ENV echo "APK_FILE=$APK_FILE" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $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 - name: Create Release and Upload APK
env: env:
AUTH: ${{ secrets.AUTHB64 }} AUTH: ${{ secrets.AUTHB64 }}
@@ -59,38 +65,33 @@ jobs:
run: | run: |
echo "Creating release for ${VERSION}..." echo "Creating release for ${VERSION}..."
# 删除已存在的 release # 尝试不同的 API endpoint
EXISTING=$(curl -s -H "Authorization: Basic ${AUTH}" "https://gitea.kg8.net/api/v1/repos/${REPO}/releases/tags/${VERSION}") for API_URL in "https://gitea.kg8.net/api/v1" "http://localhost:3000/api/v1" "http://127.0.0.1:3000/api/v1"; do
RELEASE_ID=$(echo "$EXISTING" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) 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 "❌ Failed to create release on all endpoints"
echo "删除已存在的 Release (ID: ${RELEASE_ID})" exit 1
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 上传成功!'