hex/scripts/build-app.sh
Dax Raad ecb228b8a0 feat(updater): one in-app updater on the Anomaly release service; drop Sparkle
Hex polls anoma.ly/release/hex/desktop/<channel>.json on every OS and decides
with the release protocol's client rules (the service's shared test vectors in
tests/fixtures/release-protocol): strictly newer unless revoked, the minimum
version before rollout, and a device-local rollout bucket that is never sent.
Direct installs (Linux and Windows with the installer's receipt, macOS a
replaceable Hex.app) download resumably, check size and SHA-256, then the OS
code signature (macOS app/update-requirement.txt: Developer ID 5NZ4Q7NXJ4,
anomaly.hex, notarized; Windows Authenticode from Anomaly's Artifact Signing
identity), and stage the update for Restart to update. macOS swaps the bundle
in with renamex_np(RENAME_SWAP) at restart or quit; a read-only location links
to the DMG. Package-managed installs show their manager's command; source and
test builds never check; DisableUpdates (macOS defaults, Windows policy key)
turns checks off.

Sparkle, its framework, Info.plist keys, appcast generation, and the ed25519
feeds are gone. release-app.sh prepare leaves Hex-<v>-macos-arm64.dmg and .zip
(root Hex.app). Macs on 2.3.1 get packaging/macos/legacy-appcast.xml: one
informational item linking to anoma.ly/hex.
2026-10-24 11:03:26 -04:00

86 lines
3.6 KiB
Shell
Executable file

#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
. "$root/scripts/macos-signing.sh"
# HEX_TEST_BUILD=1 builds the CI test app: ad-hoc signed, under its own
# name and bundle ID so it installs beside the released Hex and never
# touches its permissions; it never checks for updates.
if [ "${HEX_TEST_BUILD:-}" = 1 ]; then
team_id=
identity=-
app_name="Hex Test"
bundle_id=anomaly.hex.test
else
team_id=${VOICE_CONTROL_TEAM_ID:?Set VOICE_CONTROL_TEAM_ID to the Apple Developer signing team}
identity=$(hex_codesign_identity "$team_id")
app_name=Hex
bundle_id=anomaly.hex
fi
icon_output="$root/target/AppIcon.assets"
icon_info="$root/target/AppIcon-info.plist"
version=$(hex_version "$root")
build_number=$(hex_build_number "$version")
bundle_name="$app_name.app"
executable_name=hex
bundle="$root/target/app/$bundle_name"
executable="$bundle/Contents/MacOS/$executable_name"
frameworks="$bundle/Contents/Frameworks"
sign() {
if [ "$identity" = - ]; then
codesign --force --sign - "$@"
else
codesign --force --timestamp --options runtime --sign "$identity" "$@"
fi
}
export MACOSX_DEPLOYMENT_TARGET=15.0
cargo build --locked --release --manifest-path "$root/Cargo.toml"
rm -rf "$bundle"
mkdir -p "$bundle/Contents/MacOS" "$bundle/Contents/Resources" "$bundle/Contents/Library" "$frameworks"
cp "$root/target/release/voice-control" "$executable"
cp "$root/app/Info.plist" "$bundle/Contents/Info.plist"
cp "$root/LICENSE" "$root/THIRD_PARTY_NOTICES.md" "$bundle/Contents/Resources/"
HEX_VERSION="$version" HEX_BUILD_NUMBER="$build_number" VOICE_CONTROL_TEAM_ID="$team_id" VOICE_CONTROL_CODESIGN_IDENTITY="${identity#-}" HEX_SKIP_INSTALL_SCRIPT=1 \
"$root/scripts/build-hex-microphone-driver.sh" "$bundle/Contents/Library" >&2
(cd "$root/sdk/commands" && bun run build)
mkdir -p "$bundle/Contents/Resources/commands-sdk"
cp "$root/sdk/commands/package.json" "$bundle/Contents/Resources/commands-sdk/"
/usr/bin/ditto "$root/sdk/commands/dist" "$bundle/Contents/Resources/commands-sdk/dist"
/usr/bin/ditto "$root/sdk/commands/workspace-template" "$bundle/Contents/Resources/commands-sdk/workspace-template"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $version" "$bundle/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $build_number" "$bundle/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $bundle_id" "$bundle/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleExecutable $executable_name" "$bundle/Contents/Info.plist"
plutil -replace CFBundleName -string "$app_name" "$bundle/Contents/Info.plist"
plutil -replace CFBundleDisplayName -string "$app_name" "$bundle/Contents/Info.plist"
rm -rf "$icon_output"
mkdir -p "$icon_output"
xcrun actool "$root/app/AppIcon.icon" \
--compile "$icon_output" \
--platform macosx \
--minimum-deployment-target 15.0 \
--app-icon AppIcon \
--standalone-icon-behavior all \
--output-partial-info-plist "$icon_info" \
--output-format human-readable-text \
--warnings \
--notices >&2
cp "$icon_output/AppIcon.icns" "$icon_output/Assets.car" "$bundle/Contents/Resources/"
set -- "$root"/.venv/lib/python*/site-packages/moonshine_voice
moonshine_dir=$1
if [ ! -d "$moonshine_dir" ]; then
echo "Moonshine is not installed. Run ./scripts/setup.sh." >&2
exit 1
fi
cp "$moonshine_dir/libmoonshine.dylib" "$frameworks/"
cp "$moonshine_dir/libonnxruntime.1.23.2.dylib" "$frameworks/"
sign "$frameworks/libonnxruntime.1.23.2.dylib"
sign "$frameworks/libmoonshine.dylib"
sign "$bundle/Contents/Library/HexMicrophone.driver"
sign --entitlements "$root/app/VoiceControl.entitlements" "$bundle"
codesign --verify --deep --strict --verbose=2 "$bundle"
echo "$bundle"