-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-rn-android-apk.sh
More file actions
executable file
·71 lines (62 loc) · 1.86 KB
/
build-rn-android-apk.sh
File metadata and controls
executable file
·71 lines (62 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# Build the legacy Bitkit RN Android APK from ../bitkit and copy into aut/
#
# Inputs/roots:
# - E2E root: this repo (bitkit-e2e-tests)
# - RN root: ../bitkit (resolved relative to this script)
#
# Output:
# - Copies APK -> aut/bitkit_rn_<backend>.apk
#
# Usage:
# ./scripts/build-rn-android-apk.sh [debug|release]
# BACKEND=regtest ./scripts/build-rn-android-apk.sh
# ENV_FILE=.env.test.template ./scripts/build-rn-android-apk.sh
set -euo pipefail
E2E_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
RN_ROOT="$(cd "$E2E_ROOT/../bitkit" && pwd)"
BUILD_TYPE="${1:-debug}"
BACKEND="${BACKEND:-regtest}"
if [[ "$BUILD_TYPE" != "debug" && "$BUILD_TYPE" != "release" ]]; then
echo "ERROR: Unsupported build type: $BUILD_TYPE (expected debug|release)" >&2
exit 1
fi
if [[ -z "${ENV_FILE:-}" ]]; then
if [[ "$BACKEND" == "regtest" ]]; then
ENV_FILE=".env.test.template"
else
ENV_FILE=".env.development"
fi
fi
if [[ ! -f "$RN_ROOT/$ENV_FILE" ]]; then
echo "ERROR: Env file not found: $RN_ROOT/$ENV_FILE" >&2
exit 1
fi
echo "Building RN Android APK (BACKEND=$BACKEND, ENV_FILE=$ENV_FILE, BUILD_TYPE=$BUILD_TYPE)..."
pushd "$RN_ROOT" >/dev/null
if [[ -f .env ]]; then
cp .env .env.bak
fi
cp "$ENV_FILE" .env
E2E_TESTS=true yarn "e2e:build:android-$BUILD_TYPE"
if [[ -f .env.bak ]]; then
mv .env.bak .env
else
rm -f .env
fi
popd >/dev/null
APK_PATH="$RN_ROOT/android/app/build/outputs/apk/$BUILD_TYPE/app-universal-$BUILD_TYPE.apk"
if [[ ! -f "$APK_PATH" ]]; then
ALT_APK_PATH="$RN_ROOT/android/app/build/outputs/apk/$BUILD_TYPE/app-$BUILD_TYPE.apk"
if [[ -f "$ALT_APK_PATH" ]]; then
APK_PATH="$ALT_APK_PATH"
else
echo "ERROR: APK not found at: $APK_PATH" >&2
exit 1
fi
fi
OUT="$E2E_ROOT/aut"
mkdir -p "$OUT"
OUT_APK="$OUT/bitkit_rn_${BACKEND}.apk"
cp -f "$APK_PATH" "$OUT_APK"
echo "RN APK copied to: $OUT_APK (from $(basename "$APK_PATH"))"