#!/usr/bin/env bash set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$repo_root" [[ "$(uname -s)" == "Darwin" ]] || { echo "macOS internal packages must be built on macOS." >&2; exit 2; } target="${HOLOLAKE_MAC_TARGET:-aarch64-apple-darwin}" version="$(node scripts/internal-release-version.mjs src-tauri/tauri.conf.json "${HOLOLAKE_VERSION:-}")" output_dir="${HOLOLAKE_OUTPUT_DIR:-$repo_root/artifacts/internal/$version}" target_root="${CARGO_TARGET_DIR:-$repo_root/src-tauri/target}" bundle_dir="$target_root/$target/release/bundle/macos" app="$bundle_dir/${HOLOLAKE_APP_NAME:-HoloLake Era}.app" installer="$output_dir/HoloLake-Era-$version-Mac-internal-aarch64.dmg" tauri_config="${HOLOLAKE_TAURI_CONFIG:-}" if [[ -n "${HOLOLAKE_INSTALLER_BASENAME:-}" ]]; then installer_basename="${HOLOLAKE_INSTALLER_BASENAME//\{version\}/$version}" installer="$output_dir/${installer_basename}.dmg" fi if command -v pnpm >/dev/null 2>&1; then pnpm_cmd=(pnpm) elif command -v corepack >/dev/null 2>&1; then pnpm_cmd=(corepack pnpm) else echo "pnpm or corepack is required." >&2 exit 2 fi command -v hdiutil >/dev/null || { echo "hdiutil is required." >&2; exit 2; } mkdir -p "$output_dir" if [[ "${HOLOLAKE_SKIP_INSTALL:-0}" != "1" ]]; then "${pnpm_cmd[@]}" install --frozen-lockfile fi [[ -x "$repo_root/node_modules/.bin/tauri" ]] || { echo "Local Tauri CLI is missing; install dependencies first." >&2; exit 2; } tauri_args=(build --target "$target" --bundles app) if [[ -n "$tauri_config" ]]; then tauri_args+=(--config "$tauri_config"); fi "$repo_root/node_modules/.bin/tauri" "${tauri_args[@]}" [[ -d "$app" ]] || { echo "No macOS application bundle was produced: $app" >&2; exit 1; } node scripts/verify-internal-package-content.mjs "$app" codesign --force --deep --sign - "$app" codesign --verify --deep --strict "$app" hdiutil create -volname "HoloLake Era $version Internal" -srcfolder "$app" -ov -format UDZO "$installer" hdiutil verify "$installer" shasum -a 256 "$installer" | sed "s# .*# $(basename "$installer")#" > "$installer.sha256" echo "$installer"