This commit is contained in:
@@ -52,27 +52,28 @@ jobs:
|
|||||||
|
|
||||||
- name: Create or Update Release
|
- name: Create or Update Release
|
||||||
id: create_release
|
id: create_release
|
||||||
|
env:
|
||||||
|
GITEA_USER: ${{ secrets.GITEAUSER }}
|
||||||
|
GITEA_PASS: ${{ secrets.GITEAPASS }}
|
||||||
run: |
|
run: |
|
||||||
VERSION=${{ env.VERSION }}
|
VERSION=${{ env.VERSION }}
|
||||||
REPO="${{ github.repository }}"
|
REPO="${{ github.repository }}"
|
||||||
|
|
||||||
# 使用 GITHUB_TOKEN (Gitea 自动提供)
|
|
||||||
TOKEN="${{ secrets.ACTIONS_TOKEN }}"
|
|
||||||
|
|
||||||
echo "Creating release for $VERSION..."
|
echo "Creating release for $VERSION..."
|
||||||
|
|
||||||
# 检查 Release 是否已存在
|
# 检查 Release 是否已存在
|
||||||
EXISTING=$(curl -s -H "Authorization: token $TOKEN" "https://gitea.kg8.net/api/v1/repos/$REPO/releases/tags/$VERSION")
|
EXISTING=$(curl -s -u "$GITEA_USER:$GITEA_PASS" "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)
|
RELEASE_ID=$(echo "$EXISTING" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||||
|
|
||||||
if [ -n "$RELEASE_ID" ]; then
|
if [ -n "$RELEASE_ID" ]; then
|
||||||
echo "Release 已存在,删除旧的..."
|
echo "Release 已存在 (ID: $RELEASE_ID),删除旧的..."
|
||||||
curl -s -X DELETE -H "Authorization: token $TOKEN" "https://gitea.kg8.net/api/v1/repos/$REPO/releases/$RELEASE_ID"
|
curl -s -X DELETE -u "$GITEA_USER:$GITEA_PASS" "https://gitea.kg8.net/api/v1/repos/$REPO/releases/$RELEASE_ID"
|
||||||
|
sleep 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 创建新的 Release
|
# 创建新的 Release
|
||||||
RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/$REPO/releases" \
|
RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/$REPO/releases" \
|
||||||
-H "Authorization: token $TOKEN" \
|
-u "$GITEA_USER:$GITEA_PASS" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\":\"$VERSION\",\"name\":\"Release $VERSION\",\"draft\":false,\"prerelease\":false}")
|
-d "{\"tag_name\":\"$VERSION\",\"name\":\"Release $VERSION\",\"draft\":false,\"prerelease\":false}")
|
||||||
|
|
||||||
@@ -89,8 +90,13 @@ jobs:
|
|||||||
echo "✅ Release 创建成功 (ID: $NEW_RELEASE_ID)"
|
echo "✅ Release 创建成功 (ID: $NEW_RELEASE_ID)"
|
||||||
|
|
||||||
- name: Upload APK
|
- name: Upload APK
|
||||||
|
env:
|
||||||
|
GITEA_USER: ${{ secrets.GITEAUSER }}
|
||||||
|
GITEA_PASS: ${{ secrets.GITEAPASS }}
|
||||||
run: |
|
run: |
|
||||||
echo "Uploading: ${{ env.APK_FILE }}"
|
echo "Uploading: ${{ env.APK_FILE }}"
|
||||||
ls -lh ${{ 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" -H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" -F "attachment=@${{ 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 '✅ APK 上传成功!'
|
echo '✅ APK 上传成功!'
|
||||||
Reference in New Issue
Block a user