From 3505ece8cad4722455d8b245484c7795db20080d Mon Sep 17 00:00:00 2001 From: amos Date: Tue, 2 Jun 2026 23:33:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=20Basic=20Auth=20?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=88=9B=E5=BB=BA=20Release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/android-release.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/android-release.yml b/.gitea/workflows/android-release.yml index eef0b2b..3880e84 100644 --- a/.gitea/workflows/android-release.yml +++ b/.gitea/workflows/android-release.yml @@ -52,27 +52,28 @@ jobs: - name: Create or Update Release id: create_release + env: + GITEA_USER: ${{ secrets.GITEAUSER }} + GITEA_PASS: ${{ secrets.GITEAPASS }} run: | VERSION=${{ env.VERSION }} REPO="${{ github.repository }}" - # 使用 GITHUB_TOKEN (Gitea 自动提供) - TOKEN="${{ secrets.ACTIONS_TOKEN }}" - echo "Creating release for $VERSION..." # 检查 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) 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" + 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" + sleep 2 fi # 创建新的 Release 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" \ -d "{\"tag_name\":\"$VERSION\",\"name\":\"Release $VERSION\",\"draft\":false,\"prerelease\":false}") @@ -89,8 +90,13 @@ jobs: 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" -H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" -F "attachment=@${{ env.APK_FILE }}" - echo '✅ APK 上传成功!' + 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 上传成功!' \ No newline at end of file