# Steps run in file order, in one container, sharing /ci/build. image = "docker.io/library/debian:trixie" work_dir = "/ci/build" clone_project_to = "/ci/build/project" shell_setup = """ set -euo pipefail export ANDROID_HOME=/ci/cache/android-sdk """ timeout = 3600 memory_limit = "6g" cache = [ { path = "/ci/cache/android-sdk", max_size = "3g" }, { path = "/root/.gradle", max_size = "4g" }, ] [on] push = ["master"] tag = true [[steps]] name = "setup" timeout = 900 run_sh = """ apt-get update -qq && apt-get install -y -qq --no-install-recommends \ openjdk-21-jdk-headless curl unzip ca-certificates > /dev/null # Only for the license files. Gradle installs the platform and build-tools # that the app needs on its own. if [ ! -x "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" ]; then curl -fsSL -o /tmp/clt.zip \ "https://dl.google.com/android/repository/commandlinetools-linux-15859902_latest.zip" echo "040d3996a65543d22ec4bf73e4c37aa37a8d4af4 /tmp/clt.zip" | sha1sum -c - unzip -q /tmp/clt.zip -d /tmp/clt mkdir -p "$ANDROID_HOME/cmdline-tools" mv /tmp/clt/cmdline-tools "$ANDROID_HOME/cmdline-tools/latest" rm -r /tmp/clt /tmp/clt.zip fi (yes || true) | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses > /dev/null java -version """ [[steps]] name = "test" timeout = 1800 run_sh = "cd project && ./gradlew --no-daemon testDebugUnitTest" [[steps]] name = "build" timeout = 1800 run_sh = """ cd project ./gradlew --no-daemon assembleDebug cp app/build/outputs/apk/debug/app-debug.apk /ci/build/upapp-debug.apk """ publish_file = ["/ci/build/upapp-debug.apk"] # Needs the CI secrets ANDROID_KEYSTORE_BASE64 (base64 of a PKCS12 keystore) # and ANDROID_KEYSTORE_PASSWORD. Releases must keep the same key: Android # refuses an update signed with another key. [[steps]] name = "release" run_if = 'test -n "${CI_COMMIT_TAG}"' warn_on_fail = true timeout = 1800 run_sh = """ if [ -z "${ANDROID_KEYSTORE_BASE64:-}" ] || [ -z "${ANDROID_KEYSTORE_PASSWORD:-}" ]; then echo "WARNING: CI secrets ANDROID_KEYSTORE_BASE64 or ANDROID_KEYSTORE_PASSWORD missing. No signed release APK." exit 1 fi export ANDROID_KEYSTORE=/tmp/release.p12 ANDROID_KEY_ALIAS=upapp printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 -d > "$ANDROID_KEYSTORE" cd project ./gradlew --no-daemon assembleRelease cp app/build/outputs/apk/release/app-release.apk /ci/build/upapp-release.apk """ publish_file = ["/ci/build/upapp-release.apk"] [[steps]] name = "lint" warn_on_fail = true run_sh = "cd project && ./gradlew --no-daemon lintDebug"