Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 19 additions & 1 deletion scripts/bash.source
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -9,4 +13,18 @@ fi

if [[ ! -d "$AGGREGATED_REPORT_RESULT_DIR" ]]; then
mkdir -p "$AGGREGATED_REPORT_RESULT_DIR"
fi
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"
}
30 changes: 30 additions & 0 deletions scripts/create_universal_apk_from_aab.bash
Original file line number Diff line number Diff line change
@@ -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