Skip to content

1.3.4

1.3.4 #15

Workflow file for this run

name: Build AARs and Upload to Release
on:
release:
types: [published]
env:
LIB1_NAME: DialogFragmentUtilsLib
LIB2_NAME: DialogUtilsLib
jobs:
build-and-upload:
runs-on: ubuntu-latest
permissions:
contents: write # 必须添加这个权限
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# 添加执行权限
- name: Make gradlew executable
run: chmod +x gradlew
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Android SDK
uses: android-actions/setup-android@v2
- name: Build all AARs
run: |
./gradlew clean
./gradlew :${{ env.LIB1_NAME }}:assembleRelease
./gradlew :${{ env.LIB2_NAME }}:assembleRelease
- name: Upload AARs to Release (${{ env.LIB1_NAME }})
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.LIB1_NAME }}/build/outputs/aar/${{ env.LIB1_NAME }}-release.aar
asset_name: ${{ env.LIB1_NAME }}-release.aar
asset_content_type: application/octet-stream
- name: Upload AARs to Release (${{ env.LIB2_NAME }})
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.LIB2_NAME }}/build/outputs/aar/${{ env.LIB2_NAME }}-release.aar
asset_name: ${{ env.LIB2_NAME }}-release.aar
asset_content_type: application/octet-stream
- name: Verify Release Tag
run: |
# 严格校验Tag格式(支持v前缀和纯数字版本)
if [[ ! "${{ github.event.release.tag_name }}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid tag format. Must be like 1.0.0 or v1.0.0"
exit 1
fi
- name: Trigger JitPack Build
env:
JITPACK_TOKEN: ${{ secrets.JITPACK_TOKEN }} # GitHub PAT with repo scope
run: |
# Keep original tag format (preserve 'v' prefix)
VERSION=${{ github.event.release.tag_name }}
OWNER=${{ github.repository_owner }}
REPO=${{ github.event.repository.name }}
echo "Triggering build for: com.github.$OWNER/$REPO@$VERSION"
# JitPack API endpoint
API_URL="https://jitpack.io/api/builds/com.github.$OWNER/$REPO/$VERSION"
# Make initial build request
echo "Making initial build request"
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
-H "Authorization: Bearer $JITPACK_TOKEN" \
"$API_URL")
# Extract HTTP status and response body
HTTP_STATUS=$(echo "$RESPONSE" | grep HTTP_STATUS: | cut -d':' -f2)
BODY=$(echo "$RESPONSE" | sed '/HTTP_STATUS:/d')
echo "Initial API Response: $BODY"
echo "HTTP Status: $HTTP_STATUS"
if [[ "$HTTP_STATUS" != "200" ]]; then
echo "❌ Failed to trigger build (HTTP $HTTP_STATUS)"
exit 1
fi
# Check build status periodically
while true; do
echo "Checking build status..."
STATUS_RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \
-H "Authorization: Bearer $JITPACK_TOKEN" \
"$API_URL")
STATUS_HTTP=$(echo "$STATUS_RESPONSE" | grep HTTP_STATUS: | cut -d':' -f2)
STATUS_BODY=$(echo "$STATUS_RESPONSE" | sed '/HTTP_STATUS:/d')
# Extract status (case insensitive)
STATUS=$(echo "$STATUS_BODY" | grep -i -o '"status":"[^"]*"' | cut -d'"' -f4 | tr '[:upper:]' '[:lower:]')
if [[ "$STATUS" == "ok" ]]; then
echo "✅ Build succeeded!"
exit 0
elif [[ "$STATUS" == "error" ]]; then
echo "❌ Build failed!"
exit 1
else
echo "🔄 Build in progress (status: ${STATUS:-unknown}), waiting 30 seconds..."
sleep 30
fi
done
- name: Monitor Build Status
run: |
VERSION=${{ github.event.release.tag_name }}
echo "Monitor build progress at:"
echo "https://jitpack.io/#${{ github.repository }}/$VERSION"
echo "Note: Building may take 3-5 minutes"