Release and publish apps #31
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: Signed builds and upload to Play Store | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build-android: | |
| name: Build for Android | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Ninja | |
| run: sudo apt-get install -y ninja-build | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| - run: flutter pub get | |
| - run: dart run pdfrx:remove_wasm_modules | |
| - name: Patch pdfrx | |
| run: | | |
| PDFRX_PATH=$(find $HOME/.pub-cache -type d -name "pdfrx-*" | head -n 1) | |
| CMAKE_FILE="$PDFRX_PATH/android/CMakeLists.txt" | |
| if [ -f "$CMAKE_FILE" ]; then | |
| sed -i '2i add_link_options("LINKER:--build-id=none")' "$CMAKE_FILE" | |
| echo "Patched CMakeLists.txt in $CMAKE_FILE" | |
| else | |
| echo "CMakeLists.txt not found in expected location" | |
| exit 1 | |
| fi | |
| - name: Decode Keystore | |
| run: | | |
| echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/keystore.jks | |
| - name: Create key.properties | |
| run: | | |
| echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" > android/key.properties | |
| echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties | |
| echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties | |
| echo "storeFile=keystore.jks" >> android/key.properties | |
| - name: Build APK | |
| run: flutter build apk --release | |
| - name: Build appBundle | |
| run: flutter build appbundle | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Releases | |
| path: | | |
| build/app/outputs/flutter-apk/app-release.apk | |
| build/app/outputs/bundle/release/app-release.aab | |
| - name: Extract version from pubspec.yaml | |
| id: extract_version | |
| run: | | |
| version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r') | |
| echo "VERSION=$version" >> $GITHUB_ENV | |
| - name: Create GitHub Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: "build/app/outputs/flutter-apk/app-release.apk,build/app/outputs/bundle/release/app-release.aab" | |
| tag: v${{ env.VERSION }} | |
| token: ${{ secrets.TOKEN }} | |
| draft: true | |
| generateReleaseNotes: true | |
| - name: Create google_service_account.json | |
| run: | | |
| echo "${{ secrets.GOOGLE_SERVICE_ACCOUNT }}" | base64 --decode > android/google_service_account.json | |
| - name: Setup ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.3.0' | |
| bundler-cache: true | |
| working-directory: 'android' | |
| - name: Deploy to Play Store | |
| uses: maierj/fastlane-action@v3.1.0 | |
| with: | |
| lane: deploy | |
| subdirectory: android |