This commit is contained in:
@@ -50,53 +50,46 @@ jobs:
|
||||
echo "APK_FILE=$APK_FILE" >> $GITHUB_ENV
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Create or Update Release
|
||||
id: create_release
|
||||
env:
|
||||
GITEA_USER: ${{ secrets.GITEAUSER }}
|
||||
GITEA_PASS: ${{ secrets.GITEAPASS }}
|
||||
- name: Create Release and Upload APK
|
||||
run: |
|
||||
VERSION=${{ env.VERSION }}
|
||||
APK_FILE=${{ env.APK_FILE }}
|
||||
REPO="${{ github.repository }}"
|
||||
|
||||
echo "Creating release for $VERSION..."
|
||||
|
||||
# 检查 Release 是否已存在
|
||||
EXISTING=$(curl -s -u "$GITEA_USER:$GITEA_PASS" "https://gitea.kg8.net/api/v1/repos/$REPO/releases/tags/$VERSION")
|
||||
# 删除已存在的 release
|
||||
EXISTING=$(curl -s -u "amos:Aimi12138!" "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)
|
||||
|
||||
if [ -n "$RELEASE_ID" ]; then
|
||||
echo "Release 已存在 (ID: $RELEASE_ID),删除旧的..."
|
||||
curl -s -X DELETE -u "$GITEA_USER:$GITEA_PASS" "https://gitea.kg8.net/api/v1/repos/$REPO/releases/$RELEASE_ID"
|
||||
echo "删除已存在的 Release (ID: $RELEASE_ID)"
|
||||
curl -s -X DELETE -u "amos:Aimi12138!" "https://gitea.kg8.net/api/v1/repos/$REPO/releases/$RELEASE_ID"
|
||||
sleep 2
|
||||
fi
|
||||
|
||||
# 创建新的 Release
|
||||
RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/$REPO/releases" \
|
||||
-u "$GITEA_USER:$GITEA_PASS" \
|
||||
-u "amos:Aimi12138!" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$VERSION\",\"name\":\"Release $VERSION\",\"draft\":false,\"prerelease\":false}")
|
||||
|
||||
echo "Response: $RESPONSE"
|
||||
echo "Create Response: $RESPONSE"
|
||||
|
||||
NEW_RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||
|
||||
if [ -z "$NEW_RELEASE_ID" ]; then
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "❌ Failed to create release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "release_id=$NEW_RELEASE_ID" >> $GITHUB_OUTPUT
|
||||
echo "✅ Release 创建成功 (ID: $NEW_RELEASE_ID)"
|
||||
|
||||
- name: Upload APK
|
||||
env:
|
||||
GITEA_USER: ${{ secrets.GITEAUSER }}
|
||||
GITEA_PASS: ${{ secrets.GITEAPASS }}
|
||||
run: |
|
||||
echo "Uploading: ${{ env.APK_FILE }}"
|
||||
ls -lh ${{ env.APK_FILE }}
|
||||
curl -s -X POST "https://gitea.kg8.net/api/v1/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.release_id }}/assets" \
|
||||
-u "$GITEA_USER:$GITEA_PASS" \
|
||||
-F "attachment=@${{ env.APK_FILE }}"
|
||||
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" \
|
||||
-u "amos:Aimi12138!" \
|
||||
-F "attachment=@$APK_FILE")
|
||||
|
||||
echo "Upload Response: $UPLOAD_RESPONSE"
|
||||
echo '✅ APK 上传成功!'
|
||||
Reference in New Issue
Block a user