Build for Android and Linux #124
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: Build for Android and Linux | |
| on: | |
| release: | |
| types: [prereleased] | |
| jobs: | |
| validate-build: | |
| name: Validate APK Build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - uses: actions/setup-java@v2 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| # Navigate to the submodule and perform the necessary git operations | |
| - name: Update flutter submodule to stable branch | |
| run: | | |
| git submodule update --init --recursive | |
| cd submodules/flutter | |
| git reset --merge | |
| git checkout stable | |
| git pull origin stable | |
| cd ../.. | |
| - run: submodules/flutter/bin/flutter pub get | |
| - name: Run Flutter tests | |
| run: submodules/flutter/bin/flutter test | |
| - name: Set up signing config | |
| run: | | |
| echo "${{ secrets.ANDROID_KEY_BASE64 }}" | base64 -d - > upload-keystore.jks | |
| echo "${{ secrets.ANDROID_PROPERTIES_BASE64 }}" | base64 -d - > key.properties | |
| export X_KEYSTORE_PATH="$(pwd)/upload-keystore.jks" | |
| echo "X_KEYSTORE_PATH=$X_KEYSTORE_PATH" >> $GITHUB_ENV | |
| cp key.properties android/key.properties | |
| - name: Build Alpha APK for arm64 | |
| run: submodules/flutter/bin/flutter build apk --split-debug-info=./build-debug-files --flavor alpha --release --target-platform android-arm64 | |
| env: | |
| X_KEYSTORE_PATH: ${{ env.X_KEYSTORE_PATH }} | |
| bump-version: | |
| name: Bump Version | |
| runs-on: ubuntu-latest | |
| needs: validate-build | |
| permissions: | |
| contents: write | |
| outputs: | |
| new_version: ${{ steps.version.outputs.new_version }} | |
| version_code: ${{ steps.version.outputs.version_code }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Bump new version | |
| id: version | |
| run: | | |
| echo "${{ github.event.release.body }}" > changelog.temp | |
| python bump_new_version.py ${{ github.event.release.tag_name }} changelog.temp | |
| # Extract the new version from pubspec.yaml | |
| NEW_VERSION=$(grep "version:" pubspec.yaml | sed 's/version: \(.*\)+.*/\1/') | |
| VERSION_CODE=$(grep "version:" pubspec.yaml | sed 's/version: .*+\(.*\)/\1/') | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VERSION" | |
| echo "Version code: $VERSION_CODE" | |
| - uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| branch: master | |
| commit_message: "[auto] version bump" | |
| file_pattern: 'pubspec.* *.txt submodules/*' | |
| - name: Update the tag | |
| run: | | |
| git tag -d ${{ github.event.release.tag_name }} | |
| git push --delete origin ${{ github.event.release.tag_name }} | |
| git tag ${{ github.event.release.tag_name }} | |
| git push origin ${{ github.event.release.tag_name }} | |
| build-android: | |
| name: Build Android APK and Bundle | |
| runs-on: ubuntu-latest | |
| needs: bump-version | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: master | |
| - name: Pull latest changes including version bump | |
| run: git pull origin master | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - uses: actions/setup-java@v2 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| # Navigate to the submodule and perform the necessary git operations | |
| - name: Update flutter submodule to stable branch | |
| run: | | |
| git submodule update --init --recursive | |
| cd submodules/flutter | |
| git reset --merge | |
| git checkout stable | |
| git pull origin stable | |
| cd ../.. | |
| - run: submodules/flutter/bin/flutter pub get | |
| - name: Set up signing config | |
| run: | | |
| echo "${{ secrets.ANDROID_KEY_BASE64 }}" | base64 -d - > upload-keystore.jks | |
| echo "${{ secrets.ANDROID_PROPERTIES_BASE64 }}" | base64 -d - > key.properties | |
| export X_KEYSTORE_PATH="$(pwd)/upload-keystore.jks" | |
| echo "X_KEYSTORE_PATH=$X_KEYSTORE_PATH" >> $GITHUB_ENV | |
| cp key.properties android/key.properties | |
| - name: Build APK | |
| run: submodules/flutter/bin/flutter build apk --split-debug-info=./build-debug-files --flavor pro --release --split-per-abi | |
| env: | |
| X_KEYSTORE_PATH: ${{ env.X_KEYSTORE_PATH }} | |
| - name: Upload APK as Release asset | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| build/app/outputs/flutter-apk/app-armeabi-v7a-pro-release.apk | |
| build/app/outputs/flutter-apk/app-arm64-v8a-pro-release.apk | |
| build/app/outputs/flutter-apk/app-x86_64-pro-release.apk | |
| body: ${{ github.event.release.body }} | |
| tag_name: ${{ github.event.release.tag_name }} | |
| - name: Build app bundle | |
| run: | | |
| submodules/flutter/bin/flutter build appbundle --obfuscate --split-debug-info=./build-debug-file --flavor free | |
| submodules/flutter/bin/flutter build appbundle --obfuscate --split-debug-info=./build-debug-file --flavor pro | |
| - name: Publish on Google Play Free | |
| uses: r0adkll/upload-google-play@v1 | |
| with: | |
| serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_DEV_CONSOLE_SERVICE_ACCOUNT_JSON }} | |
| packageName: com.github.emavgl.piggybank | |
| releaseFiles: build/app/outputs/bundle/freeRelease/app-free-release.aab | |
| whatsNewDirectory: metadata/en-US | |
| - name: Publish on Google Play Pro | |
| uses: r0adkll/upload-google-play@v1 | |
| with: | |
| serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_DEV_CONSOLE_SERVICE_ACCOUNT_JSON }} | |
| packageName: com.github.emavgl.piggybankpro | |
| releaseFiles: build/app/outputs/bundle/proRelease/app-pro-release.aab | |
| whatsNewDirectory: metadata/en-US | |
| build-linux: | |
| name: Build Linux packages | |
| runs-on: ubuntu-latest | |
| needs: bump-version | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: master | |
| - name: Pull latest changes including version bump | |
| run: git pull origin master | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| # Install Linux build dependencies | |
| - name: Install Linux dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev | |
| # Navigate to the submodule and perform the necessary git operations | |
| - name: Update flutter submodule to stable branch | |
| run: | | |
| git submodule update --init --recursive | |
| cd submodules/flutter | |
| git reset --merge | |
| git checkout stable | |
| git pull origin stable | |
| cd ../.. | |
| - name: Enable Linux desktop | |
| run: submodules/flutter/bin/flutter config --enable-linux-desktop | |
| - run: submodules/flutter/bin/flutter pub get | |
| - name: Build Linux packages (.deb, .rpm, and AppImage) | |
| run: | | |
| # Add submodule Flutter to PATH first (so flutter_distributor uses it) | |
| export PATH="$(pwd)/submodules/flutter/bin:$PATH" | |
| # Install flutter_distributor | |
| dart pub global activate flutter_distributor | |
| export PATH="$HOME/.pub-cache/bin:$PATH" | |
| # Install tools for building .rpm and AppImage packages | |
| sudo apt-get install -y rpm fuse libfuse2 | |
| # Download and install appimagetool | |
| wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage | |
| chmod +x appimagetool-x86_64.AppImage | |
| sudo mv appimagetool-x86_64.AppImage /usr/local/bin/appimagetool | |
| # Verify Flutter version | |
| which flutter | |
| flutter --version | |
| # Build .deb, .rpm, and AppImage packages | |
| flutter_distributor release --name=linux-release --jobs=release-linux-deb,release-linux-rpm,release-linux-appimage | |
| - name: Upload Linux packages as Release asset | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| dist/*/*-linux.deb | |
| dist/*/*-linux.rpm | |
| dist/*/*-linux.AppImage | |
| body: ${{ github.event.release.body }} | |
| tag_name: ${{ github.event.release.tag_name }} | |