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
+30 -29
View File
@@ -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)
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
echo "Response: ${RESPONSE}"
# 创建新的 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}")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
echo "Create Response: ${RESPONSE}"
if [ -n "$RELEASE_ID" ]; then
echo "✅ Release 创建成功 (ID: ${RELEASE_ID}) via ${API_URL}"
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
# 上传 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}")
if [ -z "$RELEASE_ID" ]; then
echo "❌ Failed to create release"
exit 1
fi
echo "Upload Response: ${UPLOAD_RESPONSE}"
echo '✅ APK 上传成功!'
exit 0
fi
done
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 上传成功!'
echo "❌ Failed to create release on all endpoints"
exit 1