diff --git a/.gitea/workflows/android-release.yml b/.gitea/workflows/android-release.yml index 029bba3..343cc36 100644 --- a/.gitea/workflows/android-release.yml +++ b/.gitea/workflows/android-release.yml @@ -56,34 +56,43 @@ jobs: VERSION=${GITHUB_REF#refs/tags/} cp app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/app-${VERSION}-unsigned.apk echo "APK_NAME=app-${VERSION}-unsigned.apk" >> $GITHUB_ENV + echo "APK_VERSION=$VERSION" >> $GITHUB_ENV echo "⚠️ 注意:生成的是未签名 APK,仅用于测试。生产环境请配置签名。" - name: Create Gitea Release id: create_release - uses: actions/create-release@v1 - env: - ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - body: | - ## 自动发布的 Release - - - 版本:${{ github.ref }} - - 提交:${{ github.sha }} - - 编译时间:${{ github.event.head_commit.timestamp }} - - ### 变更日志 - ${{ github.event.head_commit.message }} + run: | + VERSION=${GITHUB_REF#refs/tags/} + echo "Creating release: $VERSION" + + # 使用 Gitea API 创建 Release + RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/amos/android-ci-demo/releases" \ + -H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"$VERSION\", + \"name\": \"Release $VERSION\", + \"body\": \"## 自动发布的 Release\n\n- 版本:$VERSION\n- 提交:${{ github.sha }}\n\n### 变更\n${{ github.event.head_commit.message }}\", + \"draft\": false, + \"prerelease\": false + }") + + echo "Response: $RESPONSE" + + # 提取 upload_url + UPLOAD_URL=$(echo $RESPONSE | grep -o '"upload_url":"[^"]*"' | cut -d'"' -f4) + echo "Upload URL: $UPLOAD_URL" + echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV - name: Upload Release APK - uses: actions/upload-release-asset@v1 - env: - ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: app/build/outputs/apk/release/${{ env.APK_NAME }} - asset_name: ${{ env.APK_NAME }} - asset_content_type: application/vnd.android.package-archive + run: | + echo "Uploading APK: ${{ env.APK_NAME }}" + echo "Upload URL: ${{ env.UPLOAD_URL }}" + + # 上传 APK 到 Release + curl -s -X POST "${{ env.UPLOAD_URL }}?name=${{ env.APK_NAME }}" \ + -H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" \ + -H "Content-Type: application/vnd.android.package-archive" \ + --data-binary "@app/build/outputs/apk/release/${{ env.APK_NAME }}" + + echo "✅ APK uploaded successfully!"