From f17413b1450d8cce741ab43386451181e4bdf46d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 16:14:51 +0000 Subject: [PATCH] release.sh uploads the Android app (Tokenmeter--android.apk) Android/build.sh also writes dist/Tokenmeter--android.apk beside the other packages; release.sh picks it up, lists it, names it when missing, and says why an unversioned Tokenmeter.apk in a folder isn't taken. README download table, Android README and Development docs updated. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EE8zW9dhPBpXN2w4VRrhph Co-Authored-By: tokenmeter1 <358883051+tokenmeter1@users.noreply.github.com> --- Android/README.md | 8 ++++++-- Android/build.sh | 8 +++++++- README.md | 5 +++-- docs/wiki/Development.md | 5 +++-- scripts/release.sh | 13 ++++++++++++- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Android/README.md b/Android/README.md index 663c0f0c..2a8d57cf 100644 --- a/Android/README.md +++ b/Android/README.md @@ -10,8 +10,8 @@ Android's share sheet, which a web view can't do on its own. ## Install -Build it (below), or take `tokenmeter-android` from a CI run's artifacts, copy `Tokenmeter.apk` to the phone and open -it. Android asks once to allow installing apps from wherever you opened it (Files, a browser). With a cable: +Download `Tokenmeter--android.apk` from the [latest release](https://github.com/tokenmeter1/Tokenmeter/releases/latest) +(or build it, below, or take `tokenmeter-android` from a CI run's artifacts), copy it to the phone and open it. Android asks once to allow installing apps from wherever you opened it (Files, a browser). With a cable: `adb install -r Android/Tokenmeter.apk`. Then, on any machine's Mesh page, press **Add a Viewer** and scan the QR code with the phone's camera. Android offers @@ -57,6 +57,10 @@ the SDK's own tools (`aapt2`, `d8`, `zipalign`, `apksigner`), with no Gradle and later on the PATH it also builds the built-in Tailscale (`tailnet/`, pure Go, no NDK; Go fetches `tailscale.com` the first time); `TAILNET=0` leaves it out. The APK is about 8 MB with it. +It writes `Android/Tokenmeter.apk`, and the same file as `dist/Tokenmeter--android.apk` beside the other +packages, where `scripts/release.sh` finds it and uploads it with the release. Build a release's APK with your kept +key (below), so that phones with the app can install it over the one they have. + Android installs an update only over a build signed with the same key. The first build makes one at `~/.android/tokenmeter-viewer.keystore`; keep it. To use your own, put `storeFile`, `storePassword`, `keyAlias` and `keyPassword` in `Android/keystore.properties`. A CI build is signed with a key made for that run, so an update from diff --git a/Android/build.sh b/Android/build.sh index 20e38cdf..4dbd8644 100755 --- a/Android/build.sh +++ b/Android/build.sh @@ -12,6 +12,10 @@ # Signing: Android installs an update only over a build signed with the same key, so the key is kept: the one # Android/keystore.properties names (storeFile, storePassword, keyAlias, keyPassword), else # ~/.android/tokenmeter-viewer.keystore, made on the first build. Keep that file to update the app later. +# +# Releases: a copy is also written to dist/Tokenmeter--android.apk, beside the other packages, where +# scripts/release.sh finds it and uploads it with them. Build a release's APK with your kept key, so phones that have +# the app can install the new one over it. set -euo pipefail cd "$(dirname "$0")" sdk=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}} @@ -62,4 +66,6 @@ fi "$tools/apksigner" sign --ks "$store" --ks-pass "pass:$pass" --key-pass "pass:$keypass" --ks-key-alias "$alias" \ --out Tokenmeter.apk "$out/aligned.apk" rm -f Tokenmeter.apk.idsig -echo "Built Android/Tokenmeter.apk ($version)" +mkdir -p ../dist +cp Tokenmeter.apk "../dist/Tokenmeter-$version-android.apk" +echo "Built Android/Tokenmeter.apk ($version), and dist/Tokenmeter-$version-android.apk for scripts/release.sh" diff --git a/README.md b/README.md index cd163de4..294b5950 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,7 @@ Tokenmeter is published as [GitHub releases](https://github.com/tokenmeter1/Toke | A Mac with Apple silicon, macOS 14 or later | `Tokenmeter-.dmg` | the app, which installs the service | | Linux with a desktop, x86_64 | `Tokenmeter--linux-x86_64.flatpak` or `Tokenmeter--linux-x86_64.tar.gz` | the window, the icon, the Plasma widget and the service | | Linux with a desktop, Arm (aarch64) | `Tokenmeter--linux-aarch64.tar.gz` | the same, for Arm | +| An Android phone or tablet | `Tokenmeter--android.apk` | the read-only viewer of your mesh ([Android/](Android/README.md)) | | A machine without a desktop (an inference server, a DGX Spark, a headless Mac) | `tokenmeter-service--.tar.gz` | the service alone, with a `.sha256` beside it to check the download | Once one machine runs Tokenmeter, you rarely need to download again: the service updates itself, and the machines of a mesh pass updates to each other ([Updates](#updates)). A machine can also install Tokenmeter on another over SSH, from its **Mesh** page or with `tokenmeter mesh install user@machine`. @@ -270,7 +271,7 @@ Made for KDE Plasma 6; [other desktops](docs/wiki/Install-Linux.md#other-desktop **Windows** (10 and 11): the service alone, built with Swift for Windows by `Windows\build.ps1` and installed by `Windows\install.ps1`, and watched from your Mac or Linux desktop as another machine of its mesh. There is no Windows download yet, and it has been compiled on very few machines. [More →](docs/wiki/Windows.md) -**Phones.** Every machine serves a read-only web dashboard at `/view/`; see [Phones, tablets and the web](#phones-tablets-and-the-web). The Android app is built from source with `Android/build.sh` ([Android/](Android/README.md)). +**Phones.** Every machine serves a read-only web dashboard at `/view/`; see [Phones, tablets and the web](#phones-tablets-and-the-web). The Android app is `Tokenmeter--android.apk` on the release page: copy it to the phone and open it ([Android/](Android/README.md)). **Intel Arc** cards and the Arc graphics in Core Ultra processors are read on Linux, next to NVIDIA and AMD: clock, power, what holds the card back, and each server's share of it. It is untested on real cards, so reports are welcome. [More →](docs/wiki/Intel-Arc.md) @@ -291,7 +292,7 @@ Useful scripts for contributors: - `scripts/package.sh` (Mac DMG and Mac service package), `scripts/package-linux.sh`, `scripts/package-flatpak.sh` and `scripts/package-service.sh` build the release files into `dist/`. - `scripts/package-linux-arm64.sh` builds the Arm (aarch64) Linux packages for a DGX Spark on an ordinary x86_64 PC, in Swift's arm64 Docker image under QEMU (`--service-only` for the service package alone). - `scripts/release.sh dist` makes the tag and the GitHub release from those files and uploads them (`--dry-run` and `--draft` to look first); run it again from another machine to add its packages to the same release. -- `Android/build.sh` builds the Android viewer app with the Android SDK's own tools. +- `Android/build.sh` builds the Android viewer app with the Android SDK's own tools, and puts a copy for the release in `dist/` (`Tokenmeter--android.apk`). [Development →](docs/wiki/Development.md) diff --git a/docs/wiki/Development.md b/docs/wiki/Development.md index 3e34a2ea..8efc1cdf 100644 --- a/docs/wiki/Development.md +++ b/docs/wiki/Development.md @@ -138,6 +138,7 @@ scripts/package.sh # on a Mac: the DMG and the Mac service package scripts/package-linux.sh # on Linux: the tarball and the Linux service package scripts/package-linux-arm64.sh # on an x86_64 Linux PC: the same two for Arm (aarch64, DGX Spark), under QEMU scripts/package-flatpak.sh # on Linux: the Flatpak +Android/build.sh # with the Android SDK: the Android app, signed with your kept key ``` Then `scripts/release.sh` makes the tag and the release on GitHub and uploads the files. It builds nothing: @@ -148,9 +149,9 @@ scripts/release.sh dist # tag v, publish, upload scripts/release.sh ~/mac-dist ~/linux-dist # packages gathered from several machines ``` -It takes the version from the file names, checks each service package against its `.sha256` (and makes the checksum file where one is missing), lists what a whole release would also carry, and asks before it publishes. Run it again from another machine to add that machine's packages to the same release: files the release already has are left alone (`--replace` uploads them again). `--draft` leaves the release for you to look at first; a draft is offered to nobody. The tag points at the commit checked out where you run it (`--commit` names another), which must be pushed. It needs GitHub's `gh` tool, signed in once with `gh auth login`. `scripts/release.sh --help` lists the rest. +It takes the version from the file names, checks each service package against its `.sha256` (and makes the checksum file where one is missing), lists what a whole release would also carry (the Android app among them, `Tokenmeter--android.apk`), and asks before it publishes. Run it again from another machine to add that machine's packages to the same release: files the release already has are left alone (`--replace` uploads them again). `--draft` leaves the release for you to look at first; a draft is offered to nobody. The tag points at the commit checked out where you run it (`--commit` names another), which must be pushed. It needs GitHub's `gh` tool, signed in once with `gh auth login`. `scripts/release.sh --help` lists the rest. -**By a tag**, when GitHub Actions is available: pushing a tag such as `v0.7.0` runs the release workflow, which tests, builds that version, and publishes a GitHub release with an ad-hoc signed DMG, the Linux tarballs (x86_64, and aarch64 built under QEMU) and the Flatpak. One or the other for a version: a release made by `release.sh` makes the tag too, which starts this workflow where Actions runs; it then stops at its publish step because the release is already there, and changes nothing. +**By a tag**, when GitHub Actions is available: pushing a tag such as `v0.7.0` runs the release workflow, which tests, builds that version, and publishes a GitHub release with an ad-hoc signed DMG, the Linux tarballs (x86_64, and aarch64 built under QEMU) and the Flatpak. It leaves out the Android app, which would be signed with a key made for that run and so couldn't update the app on a phone: add it with `scripts/release.sh dist` after `Android/build.sh`. One or the other for a version: a release made by `release.sh` makes the tag too, which starts this workflow where Actions runs; it then stops at its publish step because the release is already there, and changes nothing. The release also carries the service package for each platform, `tokenmeter-service--.tar.gz`, with a `.sha256` beside it: that pair is what the machines of a mesh look for when they [update](Mesh.md#updating-the-machines). To try updates without a release, build a package with a later `APP_VERSION` (`APP_VERSION=0.8.3 scripts/package-service.sh`, after setting the same version in `App/StatusJSON.swift`) and put it in `~/.tokenmeter/updates` of one machine. `TOKENMETER_RELEASES_URL` points a service at another address than GitHub's for the latest release (a file served locally, in GitHub's format). diff --git a/scripts/release.sh b/scripts/release.sh index bb784a75..91ad5fe9 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -15,6 +15,7 @@ # Tokenmeter-.dmg scripts/package.sh, on a Mac # Tokenmeter--linux-.tar.gz and .flatpak scripts/package-linux.sh, scripts/package-flatpak.sh # tokenmeter-service--.tar.gz + .sha256 scripts/package-service.sh (the Mac one comes with package.sh) +# Tokenmeter--android.apk Android/build.sh (signed with your kept key) # The service packages are what the machines of a mesh download when they update: each is checked against its # .sha256 first, and gets one written when it has none. # @@ -54,7 +55,7 @@ while [ $# -gt 0 ]; do --dry-run) dry=yes; shift ;; --yes) yes=yes; shift ;; --replace) replace=yes; shift ;; - -h|--help) sed -n '2,30p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; + -h|--help) sed -n '2,31p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; -*) fail "unknown switch $1 (see --help)" ;; *) [ -d "$1" ] || fail "$1 is not a folder" @@ -153,6 +154,16 @@ for arch in x86_64 aarch64; do done has "^Tokenmeter-$version-linux-x86_64\.flatpak$" || missing="$missing the Flatpak (Tokenmeter-$version-linux-x86_64.flatpak, from scripts/package-flatpak.sh)" +if ! has "^Tokenmeter-$version-android\.apk$"; then + missing="$missing + the Android app (Tokenmeter-$version-android.apk, from Android/build.sh, which writes it to dist/)" + # An APK that only has the build's own name says nothing of its version, so it isn't taken: build again. + printf '%s' "$folders" | while IFS= read -r folder; do + if [ -f "$folder/Tokenmeter.apk" ]; then + echo "Note: $folder/Tokenmeter.apk isn't uploaded: its name carries no version. Android/build.sh also writes dist/Tokenmeter--android.apk." + fi + done +fi # The commit the tag points at: the one checked out here unless another is named. Its own version should be the # release's, or the tag would name a commit that builds something else.