diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index d74e822..cbe0045 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -62,25 +62,34 @@ jobs: local dmg_name="$2" local volume_name="$3" - # Create a temporary directory to build DMG contents - local temp_dir="dmg_contents" - mkdir "$temp_dir" + # Calculate the size of the app bundle in KB, then add a buffer (e.g., 50MB) + APP_SIZE_KB=$(du -sk "$app_path" | cut -f1) + DMG_SIZE_MB=$(( ($APP_SIZE_KB / 1024) + 5 )) - # Copy the app bundle and create the symlink - cp -r "$app_path" "$temp_dir/" - ln -s /Applications "$temp_dir/Applications" + echo "Calculated DMG size: ${DMG_SIZE_MB}MB" - # Create the DMG from the temporary directory - hdiutil create -volname "$volume_name" -srcfolder "$temp_dir" -fs APFS -ov "$dmg_name" + # Create a new, empty APFS DMG with the specified volume name and calculated size + hdiutil create -fs APFS -size "${DMG_SIZE_MB}m" -volname "$volume_name" -ov "$dmg_name" - # Clean up the temporary directory - rm -r "$temp_dir" + # Mount the newly created DMG + MOUNT_PATH="/Volumes/$volume_name" + hdiutil attach "$dmg_name" -mountpoint "$MOUNT_PATH" + + # Copy the app bundle into the mounted DMG + cp -r "$app_path" "$MOUNT_PATH/" + + # Create the symlink to /Applications inside the mounted DMG + ln -s /Applications "$MOUNT_PATH/Applications" + + # Unmount the DMG + hdiutil detach "$MOUNT_PATH" } # --- Create DMG for each architecture --- create_dmg "dist/mac/SimpliPlay.app" "dist/SimpliPlay-x64-darwin.dmg" "SimpliPlay x64" create_dmg "dist/mac-arm64/SimpliPlay.app" "dist/SimpliPlay-arm64-darwin.dmg" "SimpliPlay arm64" create_dmg "dist/mac-universal/SimpliPlay.app" "dist/SimpliPlay-universal-darwin.dmg" "SimpliPlay Universal" + working-directory: simpliplay - name: Upload artifacts