From c58cc3a25d438c3b3d40fe48b8fd1b60fcdb569b Mon Sep 17 00:00:00 2001 From: corkine Date: Tue, 24 Jun 2025 10:45:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20GitHub=20Actions=20?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=EF=BC=8C=E5=B0=86=20Java=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BB=8E=2011=20=E5=8D=87=E7=BA=A7=E5=88=B0?= =?UTF-8?q?=2017=EF=BC=8C=E5=B9=B6=E4=BF=AE=E6=94=B9=20Web=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E5=91=BD=E4=BB=A4=E4=BB=A5=E4=BD=BF=E7=94=A8=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E5=9F=BA=E7=A1=80=E8=B7=AF=E5=BE=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 91 +++++++++++++++++------------------ 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ca9a9c..f6138e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,7 +51,7 @@ jobs: if: runner.os == 'Linux' run: | sudo apt-get update -y - sudo apt-get install -y ninja-build libgtk-3-dev + sudo apt-get install -y ninja-build libgtk-3-dev zip # Android-specific setup (on Linux runner) - name: Set up Java for Android @@ -59,7 +59,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: '11' + java-version: '17' - name: Get Flutter dependencies run: flutter pub get @@ -74,7 +74,7 @@ jobs: # Build Steps - name: Build Web if: runner.os == 'Linux' - run: flutter build web --release --dart-define=APP_VERSION=${{ github.ref_name }} --dart-define=SERVER_URL=${{ secrets.SERVER_URL }} + run: flutter build web --release --base-href=/frog/ --dart-define=APP_VERSION=${{ github.ref_name }} --dart-define=SERVER_URL=${{ secrets.SERVER_URL }} - name: Build Linux if: runner.os == 'Linux' @@ -97,60 +97,59 @@ jobs: run: flutter build ios --release --no-codesign --dart-define=APP_VERSION=${{ github.ref_name }} --dart-define=SERVER_URL=${{ secrets.SERVER_URL }} # Packaging and Uploading Artifacts - - name: Package and Upload Web + - name: Package Web build if: runner.os == 'Linux' - uses: actions/upload-artifact@v4 - with: - name: web-build - path: build/web + run: zip -r web-build.zip build/web - - name: Package and Upload Linux + - name: Package Linux build if: runner.os == 'Linux' - uses: actions/upload-artifact@v4 - with: - name: linux-build - path: build/linux/x64/release/bundle + run: zip -r linux-build.zip build/linux/x64/release/bundle - - name: Package and Upload Android - if: runner.os == 'Linux' - uses: actions/upload-artifact@v4 - with: - name: android-apk - path: build/app/outputs/flutter-apk/app-release.apk - - - name: Package and Upload Windows + - name: Package Windows build if: runner.os == 'Windows' shell: pwsh - run: | - Compress-Archive -Path build/windows/x64/runner/Release/* -DestinationPath build/windows/frog_game_windows.zip + run: Compress-Archive -Path build/windows/x64/runner/Release/* -DestinationPath windows-build.zip - - name: Upload Windows Artifact - if: runner.os == 'Windows' - uses: actions/upload-artifact@v4 - with: - name: windows-build - path: build/windows/frog_game_windows.zip - - - name: Package and Upload macOS + - name: Package macOS build if: runner.os == 'macOS' - run: | - ditto -c -k --sequesterRsrc --keepParent "build/macos/Build/Products/Release/frog_game.app" "frog_game_macos.zip" + run: ditto -c -k --sequesterRsrc --keepParent "build/macos/Build/Products/Release/frog_game.app" macos-build.zip - - name: Upload macOS Artifact + - name: Package iOS build if: runner.os == 'macOS' + run: ditto -c -k --sequesterRsrc --keepParent "build/ios/iphoneos/Runner.app" ios-build.zip + + - name: Upload Artifacts uses: actions/upload-artifact@v4 with: - name: macos-build - path: frog_game_macos.zip + name: build-artifacts-${{ runner.os }} + path: | + build/app/outputs/flutter-apk/app-release.apk + web-build.zip + linux-build.zip + windows-build.zip + macos-build.zip + ios-build.zip + if-no-files-found: ignore - - name: Package and Upload iOS - if: runner.os == 'macOS' - run: | - ditto -c -k --sequesterRsrc --keepParent "build/ios/iphoneos/Runner.app" "frog_game_ios.zip" - - - name: Upload iOS Artifact - if: runner.os == 'macOS' - uses: actions/upload-artifact@v4 + create_release: + name: Create GitHub Release + runs-on: ubuntu-latest + needs: [build_and_push_server, build_cross_platform] + permissions: + contents: write # 需要权限来创建Release + + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 with: - name: ios-build - path: frog_game_ios.zip \ No newline at end of file + path: artifacts/ + + - name: List downloaded files + run: ls -R artifacts + + - name: Create Release and Upload Assets + uses: softprops/action-gh-release@v2 + with: + files: artifacts/**/* + body: "自动发布版本 ${{ github.ref_name }}" + prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }} \ No newline at end of file