Files
Android/build.sh
Sylvia van Os 91551bf4e8 Start using flavours
Currently, this just allows us to remove the donation button on Google
Play without using the deprecated installer APIs.

In the future, this should allow us to also release multiple versions of
Catima (for example: WearOS is a commonly requested feature, but this
needs non-free dependencies, which may not be okay to all users).
2024-12-24 14:33:35 +01:00

66 lines
2.1 KiB
Bash
Executable File

#!/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