hex/ios/scripts/fetch-cleanup-model.sh
Ryan Vogel 295b6cd80e Fetch the cleanup tagger's Core ML model at build time instead of committing it
The 27 MB mlpackage would have been ~30x the largest file in the repo, kept in history forever. It is now the ios-model-cleanup-tagger-1 release asset; ios/scripts/fetch-cleanup-model.sh downloads it, checks its SHA-256, and skips when the pinned copy is already in place. Xcode Cloud runs it in ci_post_clone.sh before xcodegen; the folder is gitignored.

Verified the fetched package is byte-identical to the one the tests ran against (diff -r), and a second run is a no-op.
2026-11-19 20:28:34 -05:00

24 lines
960 B
Shell
Executable file

#!/bin/sh
set -eu
# Downloads the cleanup tagger's Core ML model (25 MB), kept out of git, into the keyboard
# extension's sources and checks its SHA-256. Run before `xcodegen generate`.
tag=ios-model-cleanup-tagger-1
asset=HexCleanupTagger-1.mlpackage.zip
sha256=dd681dfddaa3902a5f359056a60f94917651cc10134e465cc3063847002d52fc
ios=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
destination="$ios/HEXKeyboard/CleanupTagger"
stamp="$destination/.HexCleanupTagger.sha256"
if [ -d "$destination/HexCleanupTagger.mlpackage" ] && [ "$(cat "$stamp" 2>/dev/null)" = "$sha256" ]; then
exit 0
fi
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
curl -fsSL --retry 3 -o "$work/$asset" "https://github.com/anomalyco/hex/releases/download/$tag/$asset"
echo "$sha256 $work/$asset" | shasum -a 256 -c - >/dev/null
rm -rf "$destination/HexCleanupTagger.mlpackage"
unzip -q "$work/$asset" -d "$destination"
echo "$sha256" > "$stamp"
echo "Cleanup tagger model $tag ready"