diff --git a/.circleci/config.yml b/.circleci/config.yml index 326c9932d..b5270b3aa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,17 +63,18 @@ jobs: - .gradle key: *primary_key_of_gradle_cache - run: - name: Assemble apk + name: Assemble apk from App Bundle command: | - ./gradlew clean assembleDebug --offline + use_debug_keystore + ./gradlew bundleDebug --offline + create_universal_apk_from_aab.bash $(find frontend/android/build/outputs -name "*.aab" | head -1) - store_artifacts: - path: frontend/android/build/outputs/apk + path: frontend/android/build/outputs - run: *download_dpg - run: name: Upload an apk and create a distribution by app-manage procedure. command: | - apk_path=$(find frontend/android/build/outputs/apk -name "*.apk" | head -1) - dpg procedure app-manage on-feature-branch --app "$apk_path" --android | parse_dg_response + dpg procedure app-manage on-feature-branch --app "$UNIVERSAL_APK_PATH" --android | parse_dg_response - restore_cache: &restore_danger_cache keys: *all_keys_of_danger_cache - run: &bundle_install_for_danger @@ -90,15 +91,10 @@ jobs: name: Compare apks with the latest production apk command: | if download_latest_apk "$PWD/latest.apk"; then - # find first - export BUILT_APK_FILE_PATH="$PWD/$(find frontend/android/build/outputs/apk -name "*.apk" | head -1)" + export BUILT_APK_FILE_PATH="$UNIVERSAL_APK_PATH" export OLD_BUILT_APK_FILE_PATH="$PWD/latest.apk" - if [[ -f "$BUILT_APK_FILE_PATH" ]] && [[ -f "$OLD_BUILT_APK_FILE_PATH" ]]; then - danger_compare_apks - else - echo "Cannot find apks" 1>&2 - fi + danger_compare_apks fi vital_check: <<: *android_defaults diff --git a/scripts/bash.source b/scripts/bash.source index 4ccef3981..bed0bb066 100644 --- a/scripts/bash.source +++ b/scripts/bash.source @@ -1,3 +1,7 @@ +if [[ -z "$REPOSITORY_ROOT" ]]; then + export REPOSITORY_ROOT="$(git rev-parse --show-toplevel)" +fi + export PATH="${REPOSITORY_ROOT}/scripts:$PATH" export PATH="${REPOSITORY_ROOT}/.circleci/scripts:$PATH" export AGGREGATED_TEST_RESULT_DIR="$REPOSITORY_ROOT/test-results" @@ -9,4 +13,18 @@ fi if [[ ! -d "$AGGREGATED_REPORT_RESULT_DIR" ]]; then mkdir -p "$AGGREGATED_REPORT_RESULT_DIR" -fi \ No newline at end of file +fi + +export UNIVERSAL_APK_PATH="$REPOSITORY_ROOT/universal.apk" + +export DEBUG_KEY_ALIAS='droidkaigi_debug' +export DEBUG_KEY_PASSWORD='droidkaigi' +export DEBUG_KEY_STORE_FILE="$REPOSITORY_ROOT/frontend/android/debug.keystore" +export DEBUG_KEY_STORE_PASSWORD='droidkaigi' + +use_debug_keystore() { + export KEY_ALIAS="$DEBUG_KEY_ALIAS" + export KEY_PASSWORD="$DEBUG_KEY_PASSWORD" + export KEY_STORE_FILE="$DEBUG_KEY_STORE_FILE" + export KEY_STORE_PASSWORD="$DEBUG_KEY_STORE_PASSWORD" +} \ No newline at end of file diff --git a/scripts/create_universal_apk_from_aab.bash b/scripts/create_universal_apk_from_aab.bash new file mode 100755 index 000000000..cb7e8eaff --- /dev/null +++ b/scripts/create_universal_apk_from_aab.bash @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -eu + +BUNDLE_FILE="$1" + +VERSION='0.8.0' + +curl -sL# \ + -o bundletool.jar \ + "https://github.com/google/bundletool/releases/download/$VERSION/bundletool-all-$VERSION.jar" + +java -jar bundletool.jar \ + build-apks \ + --bundle="$BUNDLE_FILE" \ + --output=temp.apks \ + --overwrite \ + --mode=universal \ + --ks="$KEY_STORE_FILE" \ + --ks-key-alias="$KEY_ALIAS" \ + --ks-pass="pass:$KEY_STORE_PASSWORD" \ + --key-pass="pass:$KEY_PASSWORD" + +unzip temp.apks + +if [[ "$PWD/universal.apk" != "$UNIVERSAL_APK_PATH" ]]; then + cp universal.apk "$UNIVERSAL_APK_PATH" +fi + +rm temp.apks \ No newline at end of file