fix: 修复 IPA 重新打包时的文件覆盖问题 #35
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Android - Google Play Store Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| track: | |
| description: 'Release track (internal/beta/production)' | |
| required: true | |
| default: 'internal' | |
| type: choice | |
| options: | |
| - internal | |
| - beta | |
| - production | |
| env: | |
| FLUTTER_VERSION: '3.32.2' | |
| JAVA_VERSION: '17' | |
| jobs: | |
| build-and-release-android: | |
| name: Build and Release Android to Google Play | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: ${{ env.JAVA_VERSION }} | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| channel: 'stable' | |
| cache: true | |
| - name: Get dependencies | |
| working-directory: opencli_mobile | |
| run: flutter pub get | |
| - name: Run code analysis | |
| working-directory: opencli_mobile | |
| run: flutter analyze --no-fatal-infos --no-fatal-warnings | |
| - name: Decode Keystore | |
| env: | |
| ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
| run: | | |
| echo "$ANDROID_KEYSTORE_BASE64" | base64 --decode > opencli_mobile/android/app/release.keystore | |
| - name: Create keystore.properties | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} | |
| run: | | |
| cat > opencli_mobile/android/keystore.properties << EOF | |
| storeFile=app/release.keystore | |
| storePassword=$KEYSTORE_PASSWORD | |
| keyAlias=$KEY_ALIAS | |
| keyPassword=$KEY_PASSWORD | |
| EOF | |
| - name: Build Release AAB | |
| working-directory: opencli_mobile | |
| run: | | |
| flutter build appbundle --release | |
| - name: Upload AAB Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-release-aab | |
| path: opencli_mobile/build/app/outputs/bundle/release/app-release.aab | |
| retention-days: 30 | |
| - name: Setup Ruby (for Fastlane) | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.2' | |
| bundler-cache: false | |
| - name: Install Fastlane | |
| run: | | |
| gem install fastlane | |
| - name: Deploy to Google Play | |
| working-directory: opencli_mobile/android | |
| env: | |
| PLAY_STORE_JSON_KEY: ${{ secrets.PLAY_STORE_JSON_KEY }} | |
| run: | | |
| TRACK="${{ github.event.inputs.track || 'internal' }}" | |
| AAB_PATH="${{ github.workspace }}/opencli_mobile/build/app/outputs/bundle/release/app-release.aab" | |
| echo "🚀 Deploying to track: $TRACK" | |
| echo "📦 AAB path: $AAB_PATH" | |
| echo "📊 AAB size: $(du -h "$AAB_PATH" | cut -f1)" | |
| # Run fastlane lane based on track | |
| case "$TRACK" in | |
| internal) | |
| fastlane internal aab:"$AAB_PATH" | |
| ;; | |
| beta) | |
| fastlane beta aab:"$AAB_PATH" | |
| ;; | |
| production) | |
| fastlane production aab:"$AAB_PATH" | |
| ;; | |
| *) | |
| echo "❌ Unknown track: $TRACK" | |
| exit 1 | |
| ;; | |
| esac | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: opencli_mobile/build/app/outputs/bundle/release/app-release.aab | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| notify: | |
| name: Notify on completion | |
| needs: build-and-release-android | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Send notification | |
| run: | | |
| if [ "${{ needs.build-and-release-android.result }}" == "success" ]; then | |
| echo "✅ Android release to Google Play completed successfully!" | |
| else | |
| echo "❌ Android release to Google Play failed!" | |
| exit 1 | |
| fi |