Skip to content

Commit 4b4b6d4

Browse files
committed
更新工作流
1 parent 01190b8 commit 4b4b6d4

File tree

1 file changed

+39
-30
lines changed

1 file changed

+39
-30
lines changed

.github/workflows/android-aar.yml

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -76,46 +76,55 @@ jobs:
7676
VERSION=${{ github.event.release.tag_name }}
7777
OWNER=${{ github.repository_owner }}
7878
REPO=${{ github.event.repository.name }}
79-
79+
8080
echo "Triggering build for: com.github.$OWNER/$REPO@$VERSION"
81-
81+
8282
# JitPack API endpoint
8383
API_URL="https://jitpack.io/api/builds/com.github.$OWNER/$REPO/$VERSION"
84-
85-
# Fixed 6 attempts with 10-second intervals
86-
ATTEMPTS=6
87-
RETRY_INTERVAL=30
88-
89-
for ((ATTEMPT=1; ATTEMPT<=ATTEMPTS; ATTEMPT++)); do
90-
echo "Making API call $ATTEMPT of $ATTEMPTS"
9184
92-
# Make authenticated request
93-
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
85+
# Make initial build request
86+
echo "Making initial build request"
87+
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
88+
-H "Authorization: Bearer $JITPACK_TOKEN" \
89+
"$API_URL")
90+
91+
# Extract HTTP status and response body
92+
HTTP_STATUS=$(echo "$RESPONSE" | grep HTTP_STATUS: | cut -d':' -f2)
93+
BODY=$(echo "$RESPONSE" | sed '/HTTP_STATUS:/d')
94+
95+
echo "Initial API Response: $BODY"
96+
echo "HTTP Status: $HTTP_STATUS"
97+
98+
if [[ "$HTTP_STATUS" != "200" ]]; then
99+
echo "❌ Failed to trigger build (HTTP $HTTP_STATUS)"
100+
exit 1
101+
fi
102+
103+
# Check build status periodically
104+
while true; do
105+
echo "Checking build status..."
106+
STATUS_RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
94107
-H "Authorization: Bearer $JITPACK_TOKEN" \
95108
"$API_URL")
96-
97-
# Extract HTTP status and response body
98-
HTTP_STATUS=$(echo "$RESPONSE" | grep HTTP_STATUS: | cut -d':' -f2)
99-
BODY=$(echo "$RESPONSE" | sed '/HTTP_STATUS:/d')
100-
101-
echo "API Response: $BODY"
102-
echo "HTTP Status: $HTTP_STATUS"
103-
104-
if [[ "$HTTP_STATUS" == "200" ]]; then
105-
echo "✅ Attempt $ATTEMPT: Successfully triggered JitPack build!"
109+
110+
STATUS_HTTP=$(echo "$STATUS_RESPONSE" | grep HTTP_STATUS: | cut -d':' -f2)
111+
STATUS_BODY=$(echo "$STATUS_RESPONSE" | sed '/HTTP_STATUS:/d')
112+
113+
# Extract status (case insensitive)
114+
STATUS=$(echo "$STATUS_BODY" | grep -i -o '"status":"[^"]*"' | cut -d'"' -f4 | tr '[:upper:]' '[:lower:]')
115+
116+
if [[ "$STATUS" == "ok" ]]; then
117+
echo "✅ Build succeeded!"
118+
exit 0
119+
elif [[ "$STATUS" == "error" ]]; then
120+
echo "❌ Build failed!"
121+
exit 1
106122
else
107-
echo "⚠️ Attempt $ATTEMPT: Failed with status $HTTP_STATUS"
108-
fi
109-
110-
# Wait before next attempt (except after last one)
111-
if [ $ATTEMPT -lt $ATTEMPTS ]; then
112-
echo "Waiting $RETRY_INTERVAL seconds before next attempt..."
113-
sleep $RETRY_INTERVAL
123+
echo "🔄 Build in progress (status: ${STATUS:-unknown}), waiting 30 seconds..."
124+
sleep 30
114125
fi
115126
done
116127
117-
echo "Completed all $ATTEMPTS API calls"
118-
119128
- name: Monitor Build Status
120129
run: |
121130
VERSION=${{ github.event.release.tag_name }}

0 commit comments

Comments
 (0)