.hearthforge-ci.toml
| 1 | # Steps run in file order, in one container, sharing /ci/build. |
| 2 | |
| 3 | image = "docker.io/library/debian:trixie" |
| 4 | work_dir = "/ci/build" |
| 5 | clone_project_to = "/ci/build/project" |
| 6 | shell_setup = """ |
| 7 | set -euo pipefail |
| 8 | export ANDROID_HOME=/ci/cache/android-sdk |
| 9 | """ |
| 10 | |
| 11 | timeout = 3600 |
| 12 | memory_limit = "6g" |
| 13 | |
| 14 | cache = [ |
| 15 | { path = "/ci/cache/android-sdk", max_size = "3g" }, |
| 16 | { path = "/root/.gradle", max_size = "4g" }, |
| 17 | ] |
| 18 | |
| 19 | [on] |
| 20 | push = ["master"] |
| 21 | tag = true |
| 22 | |
| 23 | [[steps]] |
| 24 | name = "setup" |
| 25 | timeout = 900 |
| 26 | run_sh = """ |
| 27 | apt-get update -qq && apt-get install -y -qq --no-install-recommends \ |
| 28 | openjdk-21-jdk-headless curl unzip ca-certificates > /dev/null |
| 29 | |
| 30 | # Only for the license files. Gradle installs the platform and build-tools |
| 31 | # that the app needs on its own. |
| 32 | if [ ! -x "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" ]; then |
| 33 | curl -fsSL -o /tmp/clt.zip \ |
| 34 | "https://dl.google.com/android/repository/commandlinetools-linux-15859902_latest.zip" |
| 35 | echo "040d3996a65543d22ec4bf73e4c37aa37a8d4af4 /tmp/clt.zip" | sha1sum -c - |
| 36 | unzip -q /tmp/clt.zip -d /tmp/clt |
| 37 | mkdir -p "$ANDROID_HOME/cmdline-tools" |
| 38 | mv /tmp/clt/cmdline-tools "$ANDROID_HOME/cmdline-tools/latest" |
| 39 | rm -r /tmp/clt /tmp/clt.zip |
| 40 | fi |
| 41 | (yes || true) | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses > /dev/null |
| 42 | |
| 43 | java -version |
| 44 | """ |
| 45 | |
| 46 | [[steps]] |
| 47 | name = "test" |
| 48 | timeout = 1800 |
| 49 | run_sh = "cd project && ./gradlew --no-daemon testDebugUnitTest" |
| 50 | |
| 51 | [[steps]] |
| 52 | name = "build" |
| 53 | timeout = 1800 |
| 54 | run_sh = """ |
| 55 | cd project |
| 56 | ./gradlew --no-daemon assembleDebug |
| 57 | cp app/build/outputs/apk/debug/app-debug.apk /ci/build/upapp-debug.apk |
| 58 | """ |
| 59 | publish_file = ["/ci/build/upapp-debug.apk"] |
| 60 | |
| 61 | # Needs the CI secrets ANDROID_KEYSTORE_BASE64 (base64 of a PKCS12 keystore) |
| 62 | # and ANDROID_KEYSTORE_PASSWORD. Releases must keep the same key: Android |
| 63 | # refuses an update signed with another key. |
| 64 | [[steps]] |
| 65 | name = "release" |
| 66 | run_if = 'test -n "${CI_COMMIT_TAG}"' |
| 67 | warn_on_fail = true |
| 68 | timeout = 1800 |
| 69 | run_sh = """ |
| 70 | if [ -z "${ANDROID_KEYSTORE_BASE64:-}" ] || [ -z "${ANDROID_KEYSTORE_PASSWORD:-}" ]; then |
| 71 | echo "WARNING: CI secrets ANDROID_KEYSTORE_BASE64 or ANDROID_KEYSTORE_PASSWORD missing. No signed release APK." |
| 72 | exit 1 |
| 73 | fi |
| 74 | export ANDROID_KEYSTORE=/tmp/release.p12 ANDROID_KEY_ALIAS=upapp |
| 75 | printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 -d > "$ANDROID_KEYSTORE" |
| 76 | cd project |
| 77 | ./gradlew --no-daemon assembleRelease |
| 78 | cp app/build/outputs/apk/release/app-release.apk /ci/build/upapp-release.apk |
| 79 | """ |
| 80 | publish_file = ["/ci/build/upapp-release.apk"] |
| 81 | |
| 82 | [[steps]] |
| 83 | name = "lint" |
| 84 | warn_on_fail = true |
| 85 | run_sh = "cd project && ./gradlew --no-daemon lintDebug" |
| 86 |