@@ -2,52 +2,64 @@ name: Publish to JitPack on Release
22
33on :
44 release :
5- types : [published] # 只在发布正式Release时触发
5+ types : [published]
66
77jobs :
88 publish :
99 runs-on : ubuntu-latest
10-
11- # 可选:排除预发布版本
1210 if : ${{ !github.event.release.prerelease }}
1311
1412 steps :
1513 - name : Checkout code
1614 uses : actions/checkout@v4
1715 with :
18- fetch-depth : 0 # JitPack需要完整的git历史记录
16+ fetch-depth : 0
1917
2018 - name : Verify Release Tag
21- id : verify-tag
2219 run : |
23- # 检查tag名称是否符合语义化版本规范
24- if [[ ! ${{ github.event.release.tag_name }} =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+)?$ ]]; then
25- echo "::error::Tag name ${{ github.event.release.tag_name }} does not follow semantic versioning"
20+ if [[ ! "${{ github.event.release.tag_name }}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
21+ echo "::error::Invalid version tag: ${{ github.event.release.tag_name }}"
2622 exit 1
2723 fi
28- echo "Valid tag: ${{ github.event.release.tag_name }}"
24+
25+ - name : Setup Java
26+ uses : actions/setup-java@v3
27+ with :
28+ java-version : ' 17'
29+ distribution : ' temurin'
30+
31+ - name : Setup Android SDK
32+ uses : android-actions/setup-android@v2
2933
3034 - name : Trigger JitPack build
3135 env :
3236 JITPACK_TOKEN : ${{ secrets.JITPACK_TOKEN }}
3337 run : |
34- # 提取版本号(去掉可能的v前缀)
35- VERSION=${GITHUB_REF#refs/tags/}
36- VERSION=${VERSION#v} # 去掉v前缀
38+ VERSION=${{ github.event.release.tag_name }}
39+ echo "Triggering build for version: $VERSION"
3740
38- echo "Triggering JitPack build for version $VERSION"
41+ # 调试:显示仓库信息
42+ echo "Repository: ${{ github.repository }}"
43+ echo "Owner: ${{ github.repository_owner }}"
3944
40- # 使用JitPack API触发构建
41- curl -X POST "https://jitpack.io/api/build" \
45+ RESPONSE=$(curl -v -X POST "https://jitpack.io/api/build" \
4246 -H "Content-Type: application/json" \
4347 -d "{
4448 \"groupId\": \"com.github.${{ github.repository_owner }}\",
4549 \"artifactId\": \"${{ github.event.repository.name }}\",
4650 \"version\": \"$VERSION\"
4751 }" \
48- -u "${{ github.repository_owner }}:$JITPACK_TOKEN"
52+ -u "${{ github.repository_owner }}:$JITPACK_TOKEN")
53+
54+ echo "API Response: $RESPONSE"
55+ if [[ -z "$RESPONSE" || $RESPONSE != *"status"* ]]; then
56+ echo "::error::JitPack API request failed"
57+ exit 1
58+ fi
4959
50- - name : Verify JitPack Build
60+ - name : Verify Build Status
5161 run : |
52- echo "Check build status at:"
62+ VERSION=${{ github.event.release.tag_name }}
63+ echo "Check build progress at:"
5364 echo "https://jitpack.io/#${{ github.repository }}/$VERSION"
65+ echo "If not started, manually click 'Build' on JitPack page"
0 commit comments