Skip to content

Commit d5a2e62

Browse files
committed
工作流调整
1 parent 57ff79a commit d5a2e62

2 files changed

Lines changed: 66 additions & 64 deletions

File tree

.github/workflows/android-aar.yml

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
steps:
1919
- name: Checkout code
2020
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
2123

2224
# 添加执行权限
2325
- name: Make gradlew executable
@@ -56,4 +58,67 @@ jobs:
5658
upload_url: ${{ github.event.release.upload_url }}
5759
asset_path: ${{ env.LIB2_NAME }}/build/outputs/aar/${{ env.LIB2_NAME }}-release.aar
5860
asset_name: ${{ env.LIB2_NAME }}-release.aar
59-
asset_content_type: application/octet-stream
61+
asset_content_type: application/octet-stream
62+
63+
- name: Verify Release Tag
64+
run: |
65+
# 严格校验Tag格式(支持v前缀和纯数字版本)
66+
if [[ ! "${{ github.event.release.tag_name }}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
67+
echo "::error::Invalid tag format. Must be like 1.0.0 or v1.0.0"
68+
exit 1
69+
fi
70+
71+
- name: Trigger JitPack Build
72+
env:
73+
JITPACK_TOKEN: ${{ secrets.JITPACK_TOKEN }} # GitHub PAT with repo scope
74+
run: |
75+
# Keep original tag format (preserve 'v' prefix)
76+
VERSION=${{ github.event.release.tag_name }}
77+
OWNER=${{ github.repository_owner }}
78+
REPO=${{ github.event.repository.name }}
79+
80+
echo "Triggering build for: com.github.$OWNER/$REPO@$VERSION"
81+
82+
# JitPack API endpoint
83+
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=10
88+
89+
for ((ATTEMPT=1; ATTEMPT<=ATTEMPTS; ATTEMPT++)); do
90+
echo "Making API call $ATTEMPT of $ATTEMPTS"
91+
92+
# Make authenticated request
93+
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
94+
-H "Authorization: Bearer $JITPACK_TOKEN" \
95+
"$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!"
106+
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
114+
fi
115+
done
116+
117+
echo "Completed all $ATTEMPTS API calls"
118+
119+
- name: Monitor Build Status
120+
run: |
121+
VERSION=${{ github.event.release.tag_name }}
122+
echo "Monitor build progress at:"
123+
echo "https://jitpack.io/#${{ github.repository }}/$VERSION"
124+
echo "Note: Building may take 3-5 minutes"

.github/workflows/gradle-publish-jitpack.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)