-
-
Notifications
You must be signed in to change notification settings - Fork 154
/
build.sh
executable file
·65 lines (53 loc) · 2.11 KB
/
build.sh
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
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
### build.sh
### Builds Catima the same way rbtlog/IzzyOnDroid does for reproducible builds
if [ -z "${ANDROID_SDK_ROOT:-}" ]; then
echo "ANDROID_SDK_ROOT is not set, setting to $HOME/Android/Sdk";
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
fi
if [ -z "${JAVA_HOME:-}" ]; then
echo "JAVA_HOME is not set, setting to Java 17"
if [ -f "/etc/debian_version" ]; then
echo "Debian-based distro, Java 17 is /usr/lib/jvm/java-17-openjdk-amd64"
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
else
echo "Not Debian-based, assuming Fedora and setting Java 17 as /usr/lib/jvm/java-17-openjdk"
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
fi
fi
echo "Starting build"
./gradlew clean assembleRelease
echo "Build finished (unsigned)"
flavourDirs=$(find app/build/outputs/apk/ -mindepth 1 -maxdepth 1 -type d)
for flavourDir in $flavourDirs; do
flavourName="$(basename "$flavourDir")"
echo "Your $flavourName flavour is at $flavourDir/release/app-$flavourName-release-unsigned.apk"
done
if [ -z "${KEYSTORE:-}" ]; then
echo "KEYSTORE not set, skipping signing..."
else
if [ -z "${KEYSTORE_ALIAS:-}" ]; then
echo "KEYSTORE_ALIAS is not set, setting to catima"
KEYSTORE_ALIAS=catima
fi
apksigner_version="$(ls -1 "$HOME/Android/Sdk/build-tools/" | tail -n 1)"
for flavourDir in $flavourDirs; do
flavourName="$(basename "$flavourDir")"
echo "Signing $flavourName flavour..."
cp "$flavourDir/release/app-$flavourName-release-unsigned.apk" "$flavourDir/release/app-$flavourName-release.apk"
"$HOME/Android/Sdk/build-tools/$apksigner_version/apksigner" sign -v --ks "$KEYSTORE" --ks-key-alias "$KEYSTORE_ALIAS" "$flavourDir/release/app-$flavourName-release.apk"
echo "Build finished (signed)"
echo "Your $flavourName flavour is at $flavourDir/release/app-$flavourName-release.apk"
done
shasumPath="$(pwd)/SHA256SUMS"
echo "" > "$shasumPath"
for flavourDir in $flavourDirs; do
pushd "$flavourDir/release/"
sha256sum -- *.apk >> "$shasumPath"
popd
done
echo "SHA256SUMS generated"
echo "Your SHA256SUMS are at SHA256SUMS"
fi