From 1a640609c7137b2df1ae8f1e62a3455c8dc82012 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 28 Jan 2023 17:24:42 -0600 Subject: [PATCH] chore(mobile): Build and sign APK in GitHub Action (#1471) * chore(mobile): Build and sign APK in GitHUb Action * fix-1: working directory * fix-2: working directory * fix-3: key ALIAS * fix-4: build apk * fix-5: naming --- .github/workflows/build-mobile.yml | 55 ++++++++++++++++++++++++++++++ .gitignore | 2 +- mobile/android/app/build.gradle | 19 ++++++----- 3 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/build-mobile.yml diff --git a/.github/workflows/build-mobile.yml b/.github/workflows/build-mobile.yml new file mode 100644 index 0000000000..bf85137072 --- /dev/null +++ b/.github/workflows/build-mobile.yml @@ -0,0 +1,55 @@ +name: Build Mobile + +on: + workflow_dispatch: + pull_request: + push: + branches: [main] + + +jobs: + build-sign-android: + name: Build and sign Android + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: "12.x" + cache: 'gradle' + + - name: Setup Flutter SDK + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + flutter-version: '3.3.10' + cache: true + + - name: Create the Keystore + + env: + KEYSTORE_BASE64: ${{ secrets.ANDROID_SIGN_KEY_CONTENT }} + run: | + # import keystore from secrets + echo $KEYSTORE_BASE64 | base64 -d > $RUNNER_TEMP/my_production.keystore + + - name: Restore packages + working-directory: ./mobile + run: flutter pub get + + - name: Build Android App Bundle + working-directory: ./mobile + run: flutter build apk --release + + - name: Sign Android App Bundle + working-directory: ./mobile + run: jarsigner -keystore $RUNNER_TEMP/my_production.keystore -storepass ${{ secrets.ANDROID_KEY_PASSWORD }} -keypass ${{ secrets.ANDROID_STORE_PASSWORD }} -sigalg SHA256withRSA -digestalg SHA-256 -signedjar build/app/outputs/apk/release/app-release-signed.apk build/app/outputs/apk/release/*.apk ${{ secrets.ALIAS }} + + - name: Publish Android Artifact + uses: actions/upload-artifact@v1 + with: + name: release-apk-signed + path: mobile/build/app/outputs/apk/release/app-release-signed.apk \ No newline at end of file diff --git a/.gitignore b/.gitignore index cc70e48536..32ef7ed927 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ uploads coverage mobile/gradle.properties -mobile/openapi/pubspec.lock +mobile/openapi/pubspec.lock \ No newline at end of file diff --git a/mobile/android/app/build.gradle b/mobile/android/app/build.gradle index cc0de01bad..da8ed20712 100644 --- a/mobile/android/app/build.gradle +++ b/mobile/android/app/build.gradle @@ -57,20 +57,21 @@ android { versionName flutterVersionName } - signingConfigs { - release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null - storePassword keystoreProperties['storePassword'] - } - } + // signingConfigs { + // release { + // keyAlias keystoreProperties['keyAlias'] + // keyPassword keystoreProperties['keyPassword'] + // storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null + // storePassword keystoreProperties['storePassword'] + // } + // } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.release + // signingConfig signingConfigs.release + signingConfig null } } }