Skip to content

Build for Android

Build for Android #56

Workflow file for this run

name: Build for Android
on:
release:
types: [prereleased]
jobs:
build:
name: Build APK
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
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: '11'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- run: 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: Bump new version
run: |
echo "${{ github.event.release.body }}" > changelog.temp
python bump_new_version.py ${{ github.event.release.tag_name }} changelog.temp
# Commit all changed files back to the repository
- uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: master
file_pattern: 'pubspec.* *.txt'
- 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 }}
- name: Build APK
run: 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: |
flutter build appbundle --obfuscate --split-debug-info=./build-debug-file --flavor free
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