mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-30 23:14:37 +00:00
chore: standardize quote styles and add new scripts for macOS app handling
- Updated quote styles in package-and-publish.yml for consistency by converting single quotes to double quotes. - Introduced new scripts: recreate-dmg-macos.sh for DMG recreation after TDLib bundling and resign-macos.sh for re-signing the macOS app bundle, ensuring proper code signing after modifications.
This commit is contained in:
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
# Recreate macOS DMG after TDLib bundling
|
||||
# The original DMG is created by tauri-action BEFORE we bundle TDLib,
|
||||
# so we need to recreate it with the updated .app bundle.
|
||||
#
|
||||
# Usage:
|
||||
# ./recreate-dmg-macos.sh <build_type> [target]
|
||||
#
|
||||
# Arguments:
|
||||
# build_type - "release" or "debug" (default: release)
|
||||
# target - Optional cross-compilation target (e.g., aarch64-apple-darwin)
|
||||
#
|
||||
# Examples:
|
||||
# ./recreate-dmg-macos.sh release
|
||||
# ./recreate-dmg-macos.sh release aarch64-apple-darwin
|
||||
|
||||
set -e
|
||||
|
||||
BUILD_TYPE="${1:-release}"
|
||||
TARGET="${2:-}"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
TAURI_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
echo "=== macOS DMG Recreation ==="
|
||||
echo "Build type: ${BUILD_TYPE}"
|
||||
echo "Target: ${TARGET:-default}"
|
||||
|
||||
# --- Determine bundle directories ---
|
||||
# Tauri v2 puts .app in bundle/macos/ and .dmg in bundle/dmg/
|
||||
BASE_BUNDLE_DIR=""
|
||||
for search_dir in \
|
||||
"${TAURI_DIR}/target/${TARGET}/${BUILD_TYPE}/bundle" \
|
||||
"${TAURI_DIR}/target/${BUILD_TYPE}/bundle" \
|
||||
"${TAURI_DIR}/target/release/bundle" \
|
||||
"${TAURI_DIR}/target/debug/bundle"; do
|
||||
if [ -d "$search_dir/macos" ]; then
|
||||
BASE_BUNDLE_DIR="$search_dir"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$BASE_BUNDLE_DIR" ]; then
|
||||
echo "Warning: No bundle directory found"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
MACOS_DIR="$BASE_BUNDLE_DIR/macos"
|
||||
DMG_DIR="$BASE_BUNDLE_DIR/dmg"
|
||||
|
||||
echo "Bundle base: $BASE_BUNDLE_DIR"
|
||||
|
||||
# --- Find the app bundle ---
|
||||
APP_BUNDLE=$(find "$MACOS_DIR" -name "*.app" -type d 2>/dev/null | head -1)
|
||||
if [ -z "$APP_BUNDLE" ]; then
|
||||
echo "Error: No .app bundle found in $MACOS_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
APP_NAME=$(basename "$APP_BUNDLE" .app)
|
||||
echo "App bundle: $APP_BUNDLE"
|
||||
|
||||
# --- Find the original DMG ---
|
||||
ORIGINAL_DMG=$(find "$DMG_DIR" -name "*.dmg" -type f 2>/dev/null | head -1)
|
||||
if [ -z "$ORIGINAL_DMG" ]; then
|
||||
echo "Warning: No original DMG found in $DMG_DIR, skipping"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DMG_NAME=$(basename "$ORIGINAL_DMG")
|
||||
echo "Original DMG: $ORIGINAL_DMG"
|
||||
|
||||
# --- Remove old DMG and create new one ---
|
||||
echo ""
|
||||
echo "Creating new DMG..."
|
||||
rm -f "$ORIGINAL_DMG"
|
||||
hdiutil create -volname "$APP_NAME" -srcfolder "$APP_BUNDLE" -ov -format UDZO "$DMG_DIR/$DMG_NAME"
|
||||
|
||||
echo ""
|
||||
echo "=== DMG recreation complete ==="
|
||||
ls -lh "$DMG_DIR/$DMG_NAME"
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
#!/bin/bash
|
||||
# Re-sign macOS app bundle after TDLib bundling
|
||||
# Required because modifying the bundle invalidates the original code signature.
|
||||
#
|
||||
# Usage:
|
||||
# ./resign-macos.sh <build_type> [target]
|
||||
#
|
||||
# Arguments:
|
||||
# build_type - "release" or "debug" (default: release)
|
||||
# target - Optional cross-compilation target (e.g., aarch64-apple-darwin)
|
||||
#
|
||||
# Environment variables:
|
||||
# APPLE_SIGNING_IDENTITY - Signing identity (e.g., "Developer ID Application: ...")
|
||||
# If unset, uses ad-hoc signing ("-") for local testing.
|
||||
# APPLE_CERTIFICATE - Base64-encoded .p12 certificate (CI only)
|
||||
# APPLE_CERTIFICATE_PASSWORD - Password for the .p12 certificate (CI only)
|
||||
#
|
||||
# Examples:
|
||||
# # Local testing (ad-hoc signing)
|
||||
# ./resign-macos.sh release
|
||||
#
|
||||
# # CI with identity
|
||||
# APPLE_SIGNING_IDENTITY="Developer ID Application: ..." ./resign-macos.sh release aarch64-apple-darwin
|
||||
|
||||
set -e
|
||||
|
||||
BUILD_TYPE="${1:-release}"
|
||||
TARGET="${2:-}"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
TAURI_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
SIGNING_IDENTITY="${APPLE_SIGNING_IDENTITY:--}"
|
||||
|
||||
echo "=== macOS App Re-signing ==="
|
||||
echo "Build type: ${BUILD_TYPE}"
|
||||
echo "Target: ${TARGET:-default}"
|
||||
echo "Signing identity: ${SIGNING_IDENTITY}"
|
||||
|
||||
# --- CI keychain setup (only when APPLE_CERTIFICATE is provided) ---
|
||||
KEYCHAIN_PATH=""
|
||||
if [ -n "$APPLE_CERTIFICATE" ] && [ -n "$APPLE_CERTIFICATE_PASSWORD" ]; then
|
||||
echo ""
|
||||
echo "Importing certificate into temporary keychain..."
|
||||
TEMP_DIR="${RUNNER_TEMP:-/tmp}"
|
||||
KEYCHAIN_PATH="$TEMP_DIR/tdlib-signing.keychain-db"
|
||||
KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
|
||||
|
||||
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
|
||||
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
|
||||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
|
||||
|
||||
CERT_PATH="$TEMP_DIR/certificate.p12"
|
||||
echo "$APPLE_CERTIFICATE" | base64 --decode > "$CERT_PATH"
|
||||
security import "$CERT_PATH" -P "$APPLE_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH"
|
||||
rm "$CERT_PATH"
|
||||
|
||||
security list-keychains -d user -s "$KEYCHAIN_PATH" $(security list-keychains -d user | tr -d '"')
|
||||
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
|
||||
echo "Certificate imported"
|
||||
fi
|
||||
|
||||
# --- Find the app bundle ---
|
||||
APP_BUNDLE=""
|
||||
for search_dir in \
|
||||
"${TAURI_DIR}/target/${TARGET}/${BUILD_TYPE}/bundle/macos" \
|
||||
"${TAURI_DIR}/target/${BUILD_TYPE}/bundle/macos" \
|
||||
"${TAURI_DIR}/target/release/bundle/macos" \
|
||||
"${TAURI_DIR}/target/debug/bundle/macos"; do
|
||||
if [ -d "$search_dir" ]; then
|
||||
found=$(find "$search_dir" -name "*.app" -type d 2>/dev/null | head -1)
|
||||
if [ -n "$found" ]; then
|
||||
APP_BUNDLE="$found"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$APP_BUNDLE" ]; then
|
||||
echo "Warning: No .app bundle found, nothing to sign"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Signing app bundle: $APP_BUNDLE"
|
||||
|
||||
# --- Sign bundled dylibs first (inner-to-outer signing order) ---
|
||||
FRAMEWORKS_DIR="$APP_BUNDLE/Contents/Frameworks"
|
||||
if [ -d "$FRAMEWORKS_DIR" ]; then
|
||||
for dylib in "$FRAMEWORKS_DIR"/*.dylib; do
|
||||
if [ -f "$dylib" ]; then
|
||||
echo " Signing: $(basename "$dylib")"
|
||||
codesign --force --options runtime --sign "$SIGNING_IDENTITY" "$dylib"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# --- Sign the app bundle ---
|
||||
echo " Signing: $(basename "$APP_BUNDLE")"
|
||||
codesign --force --deep --options runtime --sign "$SIGNING_IDENTITY" "$APP_BUNDLE"
|
||||
|
||||
# --- Verify ---
|
||||
echo ""
|
||||
echo "Verifying signature..."
|
||||
codesign --verify --verbose=2 "$APP_BUNDLE" 2>&1 || echo "Warning: Signature verification had issues"
|
||||
|
||||
# --- Cleanup CI keychain ---
|
||||
if [ -n "$KEYCHAIN_PATH" ]; then
|
||||
security delete-keychain "$KEYCHAIN_PATH" || true
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Re-signing complete ==="
|
||||
Reference in New Issue
Block a user