From c9ce1af2c6966c5b572f6bbd2e7f3013ec0ce38d Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sat, 18 Oct 2025 14:23:17 +0800 Subject: [PATCH] Update build Signed-off-by: bggRGjQaUbCoE --- .github/workflows/android.yml | 95 ----------------------------------- .github/workflows/build.yml | 81 +++++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 98 deletions(-) delete mode 100644 .github/workflows/android.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index bc098bd4..00000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Build for Android - -on: - workflow_call: - inputs: - sign: - description: "sign" - required: false - default: true - type: boolean - workflow_dispatch: - -jobs: - android: - name: Release Android - runs-on: ubuntu-latest - - steps: - - name: 代码迁出 - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - - name: 构建Java环境 - uses: actions/setup-java@v5 - with: - distribution: "zulu" - java-version: "17" - cache: "gradle" - cache-dependency-path: | - android/*.gradle* - android/**/gradle-wrapper.properties - - - name: 安装Flutter - uses: subosito/flutter-action@v2 - id: flutter-action - with: - channel: stable - flutter-version-file: pubspec.yaml - cache: true - - - name: apply bottom sheet patch - working-directory: ${{ env.FLUTTER_ROOT }} - run: git apply $GITHUB_WORKSPACE/lib/scripts/bottom_sheet_patch.diff - continue-on-error: true - - # - name: 下载项目依赖 - # run: flutter pub get - - - name: Write key - if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_call' && inputs.sign == 'true') }} - run: | - if [ ! -z "${{ secrets.SIGN_KEYSTORE_BASE64 }}" ]; then - echo "${{ secrets.SIGN_KEYSTORE_BASE64 }}" | base64 --decode > android/app/key.jks - echo storeFile='key.jks' >> android/key.properties - echo storePassword='${{ secrets.KEYSTORE_PASSWORD }}' >> android/key.properties - echo keyAlias='${{ secrets.KEY_ALIAS }}' >> android/key.properties - echo keyPassword='${{ secrets.KEY_PASSWORD }}' >> android/key.properties - fi - - - name: Set and Extract version - shell: pwsh - run: lib/scripts/build.ps1 android - - - name: flutter build apk - run: flutter build apk --release --split-per-abi --dart-define-from-file=pili_release.json --pub - - - name: rename - run: | - for file in build/app/outputs/flutter-apk/app-*-release.apk; do - abi=$(echo "$file" | sed -E 's|.*app-(.*)-release\.apk|\1|') - mv "$file" "PiliPlus_android_${{ env.version }}_${abi}.apk" - done - shell: bash - - - name: 上传 - uses: actions/upload-artifact@v4 - with: - name: app-arm64-v8a - path: | - PiliPlus_android_*_arm64-v8a.apk - - - name: 上传 - uses: actions/upload-artifact@v4 - with: - name: app-armeabi-v7a - path: | - PiliPlus_android_*_armeabi-v7a.apk - - - name: 上传 - uses: actions/upload-artifact@v4 - with: - name: app-x86_64 - path: | - PiliPlus_android_*_x86_64.apk diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 216acd9a..25dab85e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,9 +50,84 @@ on: jobs: android: if: ${{ github.event_name == 'pull_request' || github.event.inputs.build_android == 'true' }} - uses: ./.github/workflows/android.yml - with: - sign: ${{ github.event_name != 'pull_request' }} + name: Release Android + runs-on: ubuntu-latest + + steps: + - name: 代码迁出 + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: 构建Java环境 + uses: actions/setup-java@v5 + with: + distribution: "zulu" + java-version: "17" + cache: "gradle" + cache-dependency-path: | + android/*.gradle* + android/**/gradle-wrapper.properties + + - name: 安装Flutter + uses: subosito/flutter-action@v2 + id: flutter-action + with: + channel: stable + flutter-version-file: pubspec.yaml + cache: true + + - name: apply bottom sheet patch + working-directory: ${{ env.FLUTTER_ROOT }} + run: git apply $GITHUB_WORKSPACE/lib/scripts/bottom_sheet_patch.diff + continue-on-error: true + + - name: Write key + if: github.event_name == 'workflow_dispatch' + run: | + if [ ! -z "${{ secrets.SIGN_KEYSTORE_BASE64 }}" ]; then + echo "${{ secrets.SIGN_KEYSTORE_BASE64 }}" | base64 --decode > android/app/key.jks + echo storeFile='key.jks' >> android/key.properties + echo storePassword='${{ secrets.KEYSTORE_PASSWORD }}' >> android/key.properties + echo keyAlias='${{ secrets.KEY_ALIAS }}' >> android/key.properties + echo keyPassword='${{ secrets.KEY_PASSWORD }}' >> android/key.properties + fi + + - name: Set and Extract version + shell: pwsh + run: lib/scripts/build.ps1 android + + - name: flutter build apk + run: flutter build apk --release --split-per-abi --dart-define-from-file=pili_release.json --pub + + - name: rename + run: | + for file in build/app/outputs/flutter-apk/app-*-release.apk; do + abi=$(echo "$file" | sed -E 's|.*app-(.*)-release\.apk|\1|') + mv "$file" "PiliPlus_android_${{ env.version }}_${abi}.apk" + done + shell: bash + + - name: 上传 + uses: actions/upload-artifact@v4 + with: + name: app-arm64-v8a + path: | + PiliPlus_android_*_arm64-v8a.apk + + - name: 上传 + uses: actions/upload-artifact@v4 + with: + name: app-armeabi-v7a + path: | + PiliPlus_android_*_armeabi-v7a.apk + + - name: 上传 + uses: actions/upload-artifact@v4 + with: + name: app-x86_64 + path: | + PiliPlus_android_*_x86_64.apk ios: if: ${{ github.event_name == 'pull_request' || github.event.inputs.build_ios == 'true' }}