Files
HereIAm/create_dmg.sh
Jerico Thomas d93ce669b1 1.0.1
2025-08-01 12:29:34 -04:00

101 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# HereIAm DMG Creation Script
# Creates a distributable DMG file with the app
set -e
echo "📦 Creating DMG for HereIAm..."
echo "=============================="
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR"
# Configuration
APP_NAME="HereIAm"
VERSION="1.0.1"
DMG_NAME="${APP_NAME}-${VERSION}"
APP_PATH="dist/${APP_NAME}.app"
DMG_DIR="dmg_temp"
FINAL_DMG="dist/${DMG_NAME}.dmg"
# Check if app exists
if [ ! -d "$APP_PATH" ]; then
echo -e "${RED}❌ Error: $APP_PATH not found!${NC}"
echo "Please run './build_app.sh' first to build the app."
exit 1
fi
# Clean up any existing DMG files
echo -e "${BLUE}🧹 Cleaning up previous DMG files...${NC}"
rm -f "$FINAL_DMG"
rm -rf "$DMG_DIR"
# Create temporary DMG directory
echo -e "${BLUE}📁 Creating DMG structure...${NC}"
mkdir -p "$DMG_DIR"
# Copy app to DMG directory
echo -e "${BLUE}📋 Copying app to DMG...${NC}"
cp -R "$APP_PATH" "$DMG_DIR/"
# Create Applications symlink for easy installation
echo -e "${BLUE}🔗 Creating Applications symlink...${NC}"
ln -sf /Applications "$DMG_DIR/Applications"
# Create a README for the DMG
cat > "$DMG_DIR/README.txt" << EOF
HereIAm - Mouse Movement Monitor for macOS
Version $VERSION
Installation:
1. Drag HereIAm.app to the Applications folder
2. Launch HereIAm from Applications or Spotlight
3. Grant accessibility permissions when prompted
The app will appear in your menu bar. Right-click to access controls.
For support: jerico@tekop.net
EOF
# Calculate size needed for DMG
echo -e "${BLUE}📏 Calculating DMG size...${NC}"
SIZE=$(du -sk "$DMG_DIR" | cut -f1)
SIZE=$((SIZE + 1000)) # Add some padding
# Create the DMG
echo -e "${BLUE}💿 Creating DMG file...${NC}"
hdiutil create -srcfolder "$DMG_DIR" -volname "$APP_NAME" -fs HFS+ \
-fsargs "-c c=64,a=16,e=16" -format UDZO -imagekey zlib-level=9 "$FINAL_DMG"
# Clean up
echo -e "${BLUE}🧹 Cleaning up temporary files...${NC}"
rm -rf "$DMG_DIR"
# Verify final DMG
if [ -f "$FINAL_DMG" ]; then
dmg_size=$(du -sh "$FINAL_DMG" | cut -f1)
echo ""
echo -e "${GREEN}🎉 DMG created successfully!${NC}"
echo -e "${GREEN}📦 File: $FINAL_DMG${NC}"
echo -e "${GREEN}📏 Size: $dmg_size${NC}"
echo ""
echo -e "${YELLOW}📝 Next steps for distribution:${NC}"
echo "1. Test the DMG: open \"$FINAL_DMG\""
echo "2. For wider distribution, consider notarization:"
echo " xcrun notarytool submit \"$FINAL_DMG\" --keychain-profile \"AC_PASSWORD\""
echo "3. Upload to your website or distribution platform"
echo ""
else
echo -e "${RED}❌ DMG creation failed!${NC}"
exit 1
fi