#!/bin/bash set -e # Create macOS bundle script # Usage: create-macos-bundle.sh # # Creates a DMG with: # - Yaze.app (with assets in Resources/) # - z3ed (CLI tool) # - README.md # - LICENSE # - assets/ (for CLI tool access) VERSION_NUM="$1" ARTIFACT_NAME="$2" if [ -z "$VERSION_NUM" ] || [ -z "$ARTIFACT_NAME" ]; then echo "Usage: $0 " exit 1 fi echo "Creating macOS bundle for version: $VERSION_NUM" # Clean up any previous artifacts rm -rf Yaze.app dmg_staging # Find the build directory (support both single-config and multi-config generators) BUILD_DIR="build" if [ -f "$BUILD_DIR/bin/Release/yaze" ]; then YAZE_BIN="$BUILD_DIR/bin/Release/yaze" Z3ED_BIN="$BUILD_DIR/bin/Release/z3ed" elif [ -f "$BUILD_DIR/bin/yaze" ]; then YAZE_BIN="$BUILD_DIR/bin/yaze" Z3ED_BIN="$BUILD_DIR/bin/z3ed" elif [ -d "$BUILD_DIR/bin/yaze.app" ]; then YAZE_BIN="" # Will use bundle directly Z3ED_BIN="$BUILD_DIR/bin/z3ed" else echo "ERROR: Cannot find yaze executable in $BUILD_DIR/bin/" ls -la "$BUILD_DIR/bin/" 2>/dev/null || echo "Directory doesn't exist" exit 1 fi # macOS packaging if [ -d "$BUILD_DIR/bin/yaze.app" ]; then echo "Found macOS bundle, using it directly" cp -r "$BUILD_DIR/bin/yaze.app" ./Yaze.app else echo "Creating manual bundle from executable" mkdir -p "Yaze.app/Contents/MacOS" mkdir -p "Yaze.app/Contents/Resources" cp "$YAZE_BIN" "Yaze.app/Contents/MacOS/yaze" fi # Add assets to the bundle's Resources folder if [ -d "assets" ]; then echo "Copying assets to bundle Resources..." cp -r assets "Yaze.app/Contents/Resources/" else echo "WARNING: assets directory not found" fi # Add icon to bundle if [ -f "assets/yaze.icns" ]; then cp assets/yaze.icns "Yaze.app/Contents/Resources/" fi # Create/Update Info.plist with correct version cat > "Yaze.app/Contents/Info.plist" < CFBundleExecutable yaze CFBundleIdentifier com.yaze.editor CFBundleName Yaze CFBundleDisplayName Yaze - Zelda3 Editor CFBundleVersion $VERSION_NUM CFBundleShortVersionString $VERSION_NUM CFBundlePackageType APPL CFBundleIconFile yaze.icns NSHighResolutionCapable LSMinimumSystemVersion 11.0 EOF # Create DMG staging area with FLAT structure echo "Creating DMG staging area..." mkdir -p dmg_staging # Copy the app bundle cp -r Yaze.app dmg_staging/ # Copy z3ed CLI tool (if it exists) if [ -f "$Z3ED_BIN" ]; then echo "Including z3ed CLI tool" cp "$Z3ED_BIN" dmg_staging/ elif [ -f "$BUILD_DIR/bin/Release/z3ed" ]; then echo "Including z3ed CLI tool (Release)" cp "$BUILD_DIR/bin/Release/z3ed" dmg_staging/ else echo "NOTE: z3ed not found, skipping (may not be built)" fi # Copy assets folder for CLI tool access if [ -d "assets" ]; then cp -r assets dmg_staging/ fi # Copy documentation cp LICENSE dmg_staging/ 2>/dev/null || echo "LICENSE not found" cp README.md dmg_staging/ 2>/dev/null || echo "README.md not found" echo "=== DMG staging contents ===" ls -la dmg_staging/ # Create DMG echo "Creating DMG..." hdiutil create -srcfolder dmg_staging -format UDZO -volname "Yaze $VERSION_NUM" "$ARTIFACT_NAME.dmg" # Cleanup rm -rf Yaze.app dmg_staging echo "macOS bundle creation completed successfully!" echo "Created: $ARTIFACT_NAME.dmg"