-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·68 lines (53 loc) · 2.02 KB
/
build.sh
File metadata and controls
executable file
·68 lines (53 loc) · 2.02 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
#!/bin/bash
set -e
read -p "Keystore path [./release-key.jks]: " USER_KEYSTORE_PATH
KEYSTORE_PATH="${USER_KEYSTORE_PATH:-./release-key.jks}"
KEYSTORE_ABS_PATH=$(realpath $KEYSTORE_PATH)
if [[ ! -f "$KEYSTORE_ABS_PATH" ]]; then
echo "Keystore file not found at: $KEYSTORE_ABS_PATH"
exit 1
fi
echo "Enter keystore credentials:"
read -p "Key alias: " KEY_ALIAS
read -s -p "Keystore password: " KEYSTORE_PASSWORD; echo
rm -rf build
mkdir -p build
for appdir in */ ; do
if [[ -f "$appdir/config.json" && -f "$appdir/gradlew" ]]; then
echo "===================================="
echo "Building app in: $appdir"
cd "$appdir"
# Read config
FLAG=$(jq -r '.flag' config.json)
FILES=$(jq -r '.files[]' config.json)
# Placeholder build
echo "Building placeholder version..."
./gradlew clean assembleRelease \
-Pandroid.injected.signing.store.file=$KEYSTORE_ABS_PATH \
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \
-Pandroid.injected.signing.key.alias=$KEY_ALIAS \
-Pandroid.injected.signing.key.password=$KEYSTORE_PASSWORD
cp app/build/outputs/apk/release/app-release.apk "../build/${appdir%/}-placeholder.apk"
echo -e "\n\n"
# Flagged build
echo "Replacing placeholder string with actual flag..."
for file in $FILES; do
echo "Modifying file: $file"
sed -i "s/DROIDGROUND_FLAG_PLACEHOLDER/${FLAG//\//\\/}/g" "$file"
done
echo ""
echo "Building flagged version..."
./gradlew clean assembleRelease \
-Pandroid.injected.signing.store.file=$KEYSTORE_ABS_PATH \
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \
-Pandroid.injected.signing.key.alias=$KEY_ALIAS \
-Pandroid.injected.signing.key.password=$KEYSTORE_PASSWORD
cp app/build/outputs/apk/release/app-release.apk "../build/${appdir%/}-flag.apk"
echo "Restoring modified source files..."
git restore .
cd ..
echo "Finished building: $appdir"
echo
fi
done
echo "All builds complete. APKs are in the \"build\" folder."