Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<version>-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
Expand Down Expand Up @@ -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-<version>-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
Expand Down
8 changes: 7 additions & 1 deletion Android/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-<version>-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:-}}
Expand Down Expand Up @@ -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"
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<version>.dmg` | the app, which installs the service |
| Linux with a desktop, x86_64 | `Tokenmeter-<version>-linux-x86_64.flatpak` or `Tokenmeter-<version>-linux-x86_64.tar.gz` | the window, the icon, the Plasma widget and the service |
| Linux with a desktop, Arm (aarch64) | `Tokenmeter-<version>-linux-aarch64.tar.gz` | the same, for Arm |
| An Android phone or tablet | `Tokenmeter-<version>-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-<version>-<linux-x86_64, linux-aarch64 or macos-arm64>.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`.
Expand Down Expand Up @@ -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-<version>-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)

Expand All @@ -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-<version>-android.apk`).

[Development →](docs/wiki/Development.md)

Expand Down
5 changes: 3 additions & 2 deletions docs/wiki/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -148,9 +149,9 @@ scripts/release.sh dist # tag v<version>, 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-<version>-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-<version>-<platform>.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).

Expand Down
13 changes: 12 additions & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# Tokenmeter-<version>.dmg scripts/package.sh, on a Mac
# Tokenmeter-<version>-linux-<arch>.tar.gz and .flatpak scripts/package-linux.sh, scripts/package-flatpak.sh
# tokenmeter-service-<version>-<platform>.tar.gz + .sha256 scripts/package-service.sh (the Mac one comes with package.sh)
# Tokenmeter-<version>-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.
#
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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-<version>-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.
Expand Down
Loading