Skip to content

Android - Test and Build #52

Android - Test and Build

Android - Test and Build #52

# This is a basic workflow to help you get started with Actions
name: Android - Test and Build
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# allows that other workflows can run this one
workflow_call:
secrets:
KEY_PROPERTIES_KEY_PASSWORD:
required: true
KEY_PROPERTIES_STORE_PASSWORD:
required: true
KEY_PROPERTIES_KEY_ALIAS:
required: true
KEYSTORE_BASE64:
required: true
env:
JAVA_VERSION: "11.x"
PROPERTIES_PATH: "./android/key.properties"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-13
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Setup Java to compile Android project
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: ${{env.JAVA_VERSION}}
# get versions from pubspec
- name: set env variables
run: |
python3 ./.github/workflows/building.py set_env_flutter_version
python3 ./.github/workflows/building.py set_env_dakanji_version
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
flutter-version: ${{env.FLUTTER_VERSION}}
channel: stable
- name: Restore packages
run: flutter pub get
# get / set dakanji assets from cache
- name: Check dakanji assets in cache
id: cache-dakanji-assets-restore
uses: actions/cache/restore@v3
with:
path: tmp
key: dakanji-assets
- name: Download DaKanji assets if necessary
if: steps.cache-dakanji-assets-restore.outputs.cache-hit != 'true'
run: |
python3 setup.py --download-all --no-delete
- name: Move DaKanji assets if in cache
if: steps.cache-dakanji-assets-restore.outputs.cache-hit == 'true'
run: |
python3 setup.py --no-download
- name: Save dakanji assets to cache if not saved
if: steps.cache-dakanji-assets-restore.outputs.cache-hit != 'true'
id: cache-dakanji-assets-save
uses: actions/cache/save@v3
with:
path: tmp
key: dakanji-assets
- name: Setup DaKanji env.dart
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
run: |
python3 ./.github/workflows/create_dakanji_env.py
flutter pub run build_runner build --delete-conflicting-outputs
# TESTS
#- name: Run integration tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 29
# disk-size: 16G
# target: google_apis
# profile: Nexus 6
# ram-size: 4096M
# heap-size: 1024M
# script: |
# flutter drive --driver=test_driver/integration_test.dart --target=integration_test/draw_screen_test.dart -d emulator
# create signing files
- name: Creating the .properties file
run: |
echo keyPassword=\${{ secrets.KEY_PROPERTIES_KEY_PASSWORD }} > ${{env.PROPERTIES_PATH}}
echo storePassword=\${{ secrets.KEY_PROPERTIES_STORE_PASSWORD }} >> ${{env.PROPERTIES_PATH}}
echo keyAlias=\${{ secrets.KEY_PROPERTIES_KEY_ALIAS }} >> ${{env.PROPERTIES_PATH}}
echo storeFile=../../keys/DaKanjiRecognizer.jks >> ${{env.PROPERTIES_PATH}}
- name: Decoding base64 into a file
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > keys/DaKanjiRecognizer.jks
# build apks
- name: build apks for different architectures
run: |
flutter build apk --split-per-abi
flutter build apk
ls build/app/outputs/apk/release/
- name: rename apks
run: |
mv build/app/outputs/flutter-apk/app-arm64-v8a-release.apk DaKanji_${{env.DAKANJI_VERSION}}_arm64-v8a.apk
mv build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk DaKanji_${{env.DAKANJI_VERSION}}_armeabi-v7a.apk
mv build/app/outputs/flutter-apk/app-x86_64-release.apk DaKanji_${{env.DAKANJI_VERSION}}_x86_64.apk
mv build/app/outputs/flutter-apk/app-release.apk DaKanji_${{env.DAKANJI_VERSION}}_fat.apk
- name: Upload artifact arm64-v8a
uses: actions/upload-artifact@v3
with:
name: DaKanji_${{env.DAKANJI_VERSION}}_arm64-v8a.apk
path: DaKanji_${{env.DAKANJI_VERSION}}_arm64-v8a.apk
- name: Upload artifact armeabi-v7a
uses: actions/upload-artifact@v3
with:
name: DaKanji_${{env.DAKANJI_VERSION}}_armeabi-v7a.apk
path: DaKanji_${{env.DAKANJI_VERSION}}_armeabi-v7a.apk
- name: Upload artifact apk x86_64
uses: actions/upload-artifact@v3
with:
name: DaKanji_${{env.DAKANJI_VERSION}}_x86_64.apk
path: DaKanji_${{env.DAKANJI_VERSION}}_x86_64.apk
- name: Upload artifact fat apk
uses: actions/upload-artifact@v3
with:
name: DaKanji_${{env.DAKANJI_VERSION}}_fat.apk
path: DaKanji_${{env.DAKANJI_VERSION}}_fat.apk
# build appbundle and upload to artifacts
- name: build app bundle
run: |
python3 ./.github/workflows/building.py comment_large_assets_in_pubspec
flutter pub get
flutter build appbundle
- name: Archive appbundle
uses: actions/upload-artifact@v3
with:
name: DaKanji_${{env.DAKANJI_VERSION}}_bundle.zip
path: build/app/outputs/bundle/release/app-release.aab