Skip to content

FreeToken brings datacenter-scale model serving to your desktop. Run massive models locally, fast and efficiently.

ci: publish engine-<platform>.json manifests alongside the nightly wheels (#377)

Xiaoze Fanaf71ba43206e
diff --git a/.github/workflows/nightly-wheels.yml b/.github/workflows/nightly-wheels.yml
index 8a43ec89..5cf55434 100644
--- a/.github/workflows/nightly-wheels.yml
+++ b/.github/workflows/nightly-wheels.yml
@@ -60,13 +60,18 @@ jobs:
GH_TOKEN: ${{ github.token }}
FORCE: ${{ inputs.force }}
run: |
- head_stamp="+g${GITHUB_SHA:0:9}"
+ head_stamp="${GITHUB_SHA:0:9}"
# The release also carries win_amd64 wheels with their own stamp; this
- # workflow only builds linux, so compare the linux runtime wheel only.
- published_stamp="$(gh api "repos/$WEB_REPO/releases/tags/$WEB_TAG" \
+ # workflow only builds linux, so read the linux manifest that
+ # scripts/publish-wheels.sh writes. Before the first manifest exists, fall
+ # back to the stamp in the linux runtime wheel's name.
+ published_stamp="$(curl -fsSL \
+ "https://github.com/$WEB_REPO/releases/download/$WEB_TAG/engine-linux_x86_64.json" \
+ 2>/dev/null | jq -r '.commit // empty' || true)"
+ [ -n "$published_stamp" ] || published_stamp="$(gh api "repos/$WEB_REPO/releases/tags/$WEB_TAG" \
--jq '.assets[].name' 2>/dev/null \
| grep -E '^freetoken-.*linux_x86_64\.whl$' \
- | grep -oE '\+g[0-9a-f]{7,}' | head -1 || true)"
+ | grep -oE '\+g[0-9a-f]{7,}' | head -1 | sed 's/^+g//' || true)"
echo "HEAD: $head_stamp published: ${published_stamp:-<none>}"
if [ "$FORCE" = "true" ] || [ "$head_stamp" != "$published_stamp" ]; then
echo "build=true" >> "$GITHUB_OUTPUT"
diff --git a/scripts/publish-wheels.sh b/scripts/publish-wheels.sh
index e8a6ac41..600767aa 100755
--- a/scripts/publish-wheels.sh
+++ b/scripts/publish-wheels.sh
@@ -12,6 +12,12 @@
# install error and a retry) is the safer failure. Requires `gh` authenticated
# with write access to the target repo.
#
+# After the upload, writes `engine-<platform>.json` to the release: the pair's URLs,
+# sha256 and sizes under a fixed asset name, so a Desktop resolves the pair with one
+# static download (no api.github.com, no per-IP rate limit) and scans the asset list
+# only when the manifest is missing. One file per platform -- the linux nightly and a
+# hand-run windows publish never touch each other's manifest.
+#
# Environment:
# FREETOKEN_WEB_REPO target repo (default: FlashML-org/FreeToken-Web)
# FREETOKEN_WEB_TAG release tag (default: beta)
@@ -90,6 +96,52 @@ for w in "${wheels[@]}"; do
gh release upload "$TAG" "$w" -R "$REPO"
done
+# The manifest is written LAST so it never names a wheel that is not there yet. The
+# Desktop compares asset basenames, so the URL is spelled the way GitHub's
+# browser_download_url spells it: `+` percent-encoded.
+asset_url() { printf 'https://github.com/%s/releases/download/%s/%s' "$REPO" "$TAG" "${1//+/%2B}"; }
+wheel_json() {
+ local w="$1" name size sha
+ name="${w##*/}"
+ size="$(wc -c <"$w" | tr -d ' ')"
+ sha="$(sha256sum "$w" | cut -d' ' -f1)"
+ printf '{"name": "%s", "url": "%s", "sha256": "%s", "size": %s}' "$name" "$(asset_url "$name")" "$sha" "$size"
+}
+manifest_dir="$(mktemp -d)"
+trap 'rm -rf "$manifest_dir"' EXIT
+while IFS= read -r p; do
+ rt=""; kc=""
+ for w in "${wheels[@]}"; do
+ case "${w##*/}" in
+ freetoken-*"$p"*.whl) rt="$w" ;;
+ freetoken_kernel_cache-*"$p"*.whl) kc="$w" ;;
+ esac
+ done
+ rt_name="${rt##*/}"
+ # freetoken-<version>-<python>-<abi>-<platform>.whl
+ version="$(cut -d- -f2 <<<"$rt_name")"
+ python_tag="$(cut -d- -f3 <<<"$rt_name")"
+ commit="$(grep -oE '\+g[0-9a-f]{7,}' <<<"$rt_name" | head -1 | sed 's/^+g//' || true)"
+ cuda="$(grep -oE '\+cu[0-9]+' <<<"${kc##*/}" | head -1 | sed 's/^+//' || true)"
+ manifest="$manifest_dir/engine-$p.json"
+ cat >"$manifest" <<JSON
+{
+ "schema": 1,
+ "channel": "$TAG",
+ "platform": "$p",
+ "version": "$version",
+ "commit": "$commit",
+ "published": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
+ "python": "$python_tag",
+ "cuda": "$cuda",
+ "runtime": $(wheel_json "$rt"),
+ "kernel_cache": $(wheel_json "$kc")
+}
+JSON
+ say "uploading engine-$p.json (version $version)"
+ gh release upload "$TAG" "$manifest" -R "$REPO" --clobber
+done <<<"$platforms"
+
say "release now carries:"
gh api "repos/$REPO/releases/tags/$TAG" \
--jq '.assets[] | select(.name | endswith(".whl")) | " \(.name) \(.digest // "no-digest") \(.updated_at)"'