Add the Android shell, APK build, bridge test, sweet config and CI

android/: HomeActivity (derived from the legacy MainActivity, same package
dev.ultra.launcher and class name as the Qt build so the default-home choice
carries over), Updater reduced to httpGet + PackageInstaller, RecentsService,
manifest and resources, the committed debug keystore. android/build.sh builds
the APK with aapt2, javac, d8, zipalign and apksigner (no Gradle).
tests/android-sim.cjs drives the page against a stub of window.Android.
.sweet.config.yml / .sweet.yml with moon.mod as the annotated version file.
CI: test job (moon test on js and wasm-gc, browser tests) and an apk job that
publishes a Gitea release.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Sonnet 5.5 committed 2026-11-23 01:08:35 +00:00
1 parent 637129aa4e
commit dccbfd7d86
24 files changed
+1571 -30

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
# Builds the launcher APK (MoonBit page + Java shell, android/build.sh) and publishes it as a
# Gitea release: build-<versionCode>, holding ultra-launcher.apk and version.json, made a
# draft first and published once both files are up, so the latest release never lacks them.
# Runs in .gitea/workflows/launcher.yml's "apk" job (node:22-bookworm container, as root,
# no docker). The installed app updates itself from the latest release (updater/ in MoonBit).
set -euo pipefail
cd "$(dirname "$0")/.."
# Minutes since the epoch: always above every earlier build's versionCode (the Qt builds used
# the same scale) and always rising.
export VERSION_CODE=$(( $(date +%s) / 60 ))
COMMIT="${GITHUB_SHA:-$(git rev-parse HEAD)}"
echo "== tools"
apt-get update -qq
apt-get install -y -qq --no-install-recommends openjdk-17-jdk-headless unzip zip curl ca-certificates git >/dev/null
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
export PATH="$HOME/.moon/bin:$PATH"
moon update
echo "== Android SDK (build-tools and the platform jar only)"
export ANDROID_SDK_ROOT=/opt/android-sdk
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
curl -fsSL -o /tmp/cmdline.zip https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
unzip -q /tmp/cmdline.zip -d "$ANDROID_SDK_ROOT/cmdline-tools"
mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest"
yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses >/dev/null || true
"$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --install "build-tools;35.0.0" >/dev/null
# Only android.jar is needed from the platform: unzipping the whole thing (sdkmanager) is slow.
curl -fsSL -o /tmp/platform.zip https://dl.google.com/android/repository/platform-35_r02.zip
mkdir -p "$ANDROID_SDK_ROOT/platforms" && unzip -q /tmp/platform.zip 'android-35/android.jar' -d "$ANDROID_SDK_ROOT/platforms"
echo "== build (versionCode $VERSION_CODE)"
android/build.sh ultra-launcher.apk
echo "== release build-$VERSION_CODE"
server="${GITHUB_SERVER_URL:-https://git.site.latha.org}"
repo="${GITHUB_REPOSITORY:-experiments/launcher}"
api="${server%/}/api/v1/repos/$repo"
token="${GITEA_TOKEN:-${GITHUB_TOKEN:-}}"
test -n "$token" || { echo "no GITEA_TOKEN/GITHUB_TOKEN in the environment"; exit 1; }
auth=(-H "Authorization: token $token")
tag="build-$VERSION_CODE"
id=$(curl -fsS "${auth[@]}" -H "Content-Type: application/json" -X POST "$api/releases" \
-d "{\"tag_name\": \"$tag\", \"name\": \"ultra Home build $VERSION_CODE\", \"target_commitish\": \"$COMMIT\", \"draft\": true, \"body\": \"MoonBit launcher built from $COMMIT.\"}" \
| python3 -c 'import sys, json; print(json.load(sys.stdin)["id"])')
curl -fsS "${auth[@]}" -F "attachment=@ultra-launcher.apk" "$api/releases/$id/assets?name=ultra-launcher.apk" >/dev/null
curl -fsS "${auth[@]}" -F "attachment=@$(dirname ultra-launcher.apk)/version.json" "$api/releases/$id/assets?name=version.json" >/dev/null
curl -fsS "${auth[@]}" -H "Content-Type: application/json" -X PATCH "$api/releases/$id" -d '{"draft": false}' >/dev/null
echo "published $tag to $server/$repo"