| | |
| | | #!/usr/bin/env bash |
| | | # |
| | | # build-release-macos.sh — Build a signed & notarized macOS DMG for PrivateVoice Input |
| | | # build-release-macos.sh — Build a signed & notarized macOS DMG for PrivateVoice Dictation |
| | | # |
| | | # Prerequisites (one-time): |
| | | # 1. Install Developer ID certificate in Keychain |
| | |
| | | IDENTITY="Developer ID Application: Ningbo Zhuozhi Innovation Network Technology Co., Ltd. (3HY4G7M2AL)" |
| | | KEYCHAIN_PROFILE="privatevoice" |
| | | |
| | | APP_NAME="PrivateVoice Input" |
| | | APP_NAME="PrivateVoice Dictation" |
| | | BUNDLE_ID="com.privatevoice.input" |
| | | |
| | | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| | |
| | | ENTITLEMENTS="$PROJECT_DIR/build/darwin/entitlements.plist" |
| | | INFO_PLIST="$PROJECT_DIR/build/darwin/Info.plist" |
| | | GOMODCACHE=$(go env GOMODCACHE) |
| | | SHERPA_MACOS_MODULE_VERSION="$(cd "$PROJECT_DIR" && go list -m -f '{{.Version}}' github.com/k2-fsa/sherpa-onnx-go-macos)" |
| | | ONNXRUNTIME_DYLIB="" |
| | | ONNXRUNTIME_DYLIB_NAME="" |
| | | |
| | | # ── Architecture mapping ──────────────────────────────────────────────────── |
| | | resolve_arch() { |
| | |
| | | fail "Unknown architecture: $arch (use arm64 or x86_64)" |
| | | ;; |
| | | esac |
| | | SHERPA_LIB_DIR="$GOMODCACHE/github.com/k2-fsa/sherpa-onnx-go-macos@v1.12.24/lib/$SHERPA_ARCH" |
| | | SHERPA_LIB_DIR="$GOMODCACHE/github.com/k2-fsa/sherpa-onnx-go-macos@$SHERPA_MACOS_MODULE_VERSION/lib/$SHERPA_ARCH" |
| | | DMG_NAME="${APP_NAME}-v${VERSION}-${DMG_ARCH}.dmg" |
| | | BUILD_DIR="$PROJECT_DIR/build/release/${DMG_ARCH}" |
| | | APP_BUNDLE="$BUILD_DIR/${APP_NAME}.app" |
| | |
| | | # ── Preflight checks ───────────────────────────────────────────────────────── |
| | | step "Preflight checks" |
| | | [[ -d "$SHERPA_LIB_DIR" ]] || fail "sherpa-onnx dylibs not found at $SHERPA_LIB_DIR" |
| | | ONNXRUNTIME_DYLIB="$(find "$SHERPA_LIB_DIR" -maxdepth 1 -type f -name 'libonnxruntime.*.dylib' | sort | tail -n 1)" |
| | | [[ -f "$ONNXRUNTIME_DYLIB" ]] || fail "onnxruntime dylib not found in $SHERPA_LIB_DIR" |
| | | ONNXRUNTIME_DYLIB_NAME="$(basename "$ONNXRUNTIME_DYLIB")" |
| | | [[ -f "$ENTITLEMENTS" ]] || fail "entitlements.plist not found at $ENTITLEMENTS" |
| | | [[ -f "$INFO_PLIST" ]] || fail "Info.plist not found at $INFO_PLIST" |
| | | security find-identity -v -p codesigning | grep -q "$IDENTITY" || fail "Signing identity not found in keychain" |
| | |
| | | |
| | | # Copy dylibs |
| | | cp "$SHERPA_LIB_DIR/libsherpa-onnx-c-api.dylib" "$APP_BUNDLE/Contents/Frameworks/" |
| | | cp "$SHERPA_LIB_DIR/libonnxruntime.1.23.2.dylib" "$APP_BUNDLE/Contents/Frameworks/" |
| | | cp "$ONNXRUNTIME_DYLIB" "$APP_BUNDLE/Contents/Frameworks/" |
| | | |
| | | # ── Step 5: Fix rpaths ─────────────────────────────────────────────────────── |
| | | step "Fixing rpaths with install_name_tool" |
| | |
| | | install_name_tool -id @rpath/libsherpa-onnx-c-api.dylib \ |
| | | "$APP_BUNDLE/Contents/Frameworks/libsherpa-onnx-c-api.dylib" |
| | | |
| | | install_name_tool -id @rpath/libonnxruntime.1.23.2.dylib \ |
| | | "$APP_BUNDLE/Contents/Frameworks/libonnxruntime.1.23.2.dylib" |
| | | install_name_tool -id "@rpath/$ONNXRUNTIME_DYLIB_NAME" \ |
| | | "$APP_BUNDLE/Contents/Frameworks/$ONNXRUNTIME_DYLIB_NAME" |
| | | |
| | | # Fix libsherpa's dependency on libonnxruntime |
| | | install_name_tool -change \ |
| | | @rpath/libonnxruntime.1.23.2.dylib \ |
| | | @rpath/libonnxruntime.1.23.2.dylib \ |
| | | "@rpath/$ONNXRUNTIME_DYLIB_NAME" \ |
| | | "$APP_BUNDLE/Contents/Frameworks/libsherpa-onnx-c-api.dylib" 2>/dev/null || true |
| | | install_name_tool -change \ |
| | | @rpath/libonnxruntime.1.24.4.dylib \ |
| | | "@rpath/$ONNXRUNTIME_DYLIB_NAME" \ |
| | | "$APP_BUNDLE/Contents/Frameworks/libsherpa-onnx-c-api.dylib" 2>/dev/null || true |
| | | |
| | | # ── Step 6: Code sign ──────────────────────────────────────────────────────── |
| | |
| | | codesign --force --options runtime \ |
| | | --entitlements "$ENTITLEMENTS" \ |
| | | --sign "$IDENTITY" \ |
| | | "$APP_BUNDLE/Contents/Frameworks/libonnxruntime.1.23.2.dylib" |
| | | "$APP_BUNDLE/Contents/Frameworks/$ONNXRUNTIME_DYLIB_NAME" |
| | | |
| | | codesign --force --options runtime \ |
| | | --entitlements "$ENTITLEMENTS" \ |