This commit is contained in:
@@ -50,13 +50,27 @@ jobs:
|
|||||||
echo "APK_FILE=$APK_FILE" >> $GITHUB_ENV
|
echo "APK_FILE=$APK_FILE" >> $GITHUB_ENV
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create or Update Release
|
||||||
id: create_release
|
id: create_release
|
||||||
run: |
|
run: |
|
||||||
VERSION=${{ env.VERSION }}
|
VERSION=${{ env.VERSION }}
|
||||||
RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/${{ github.repository }}/releases" -H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" -H "Content-Type: application/json" -d "{\"tag_name\":\"$VERSION\",\"name\":\"Release $VERSION\",\"draft\":false,\"prerelease\":false}")
|
REPO="${{ github.repository }}"
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
TOKEN="${{ secrets.ACTIONS_TOKEN }}"
|
||||||
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
|
|
||||||
|
# 检查 Release 是否已存在
|
||||||
|
EXISTING=$(curl -s -H "Authorization: token $TOKEN" "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 已存在,删除旧的..."
|
||||||
|
curl -s -X DELETE -H "Authorization: token $TOKEN" "https://gitea.kg8.net/api/v1/repos/$REPO/releases/$RELEASE_ID"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 创建新的 Release
|
||||||
|
RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/$REPO/releases" -H "Authorization: token $TOKEN" -H "Content-Type: application/json" -d "{\"tag_name\":\"$VERSION\",\"name\":\"Release $VERSION\",\"draft\":false,\"prerelease\":false}")
|
||||||
|
NEW_RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||||
|
echo "release_id=$NEW_RELEASE_ID" >> $GITHUB_OUTPUT
|
||||||
|
echo "✅ Release 创建成功 (ID: $NEW_RELEASE_ID)"
|
||||||
|
|
||||||
- name: Upload APK
|
- name: Upload APK
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user