From 8046bc910563bba0b1a811dbdc5d7eb4a3cebb4b Mon Sep 17 00:00:00 2001 From: Ozgur Ersoy Date: Thu, 17 Apr 2025 11:56:08 +0200 Subject: [PATCH] fix(actions): improve DMG creation process in macOS notarization workflow by adding fallback mechanisms and detailed logging for package creation --- .gitea/workflows/test-macos-build.yml | 104 +++++++++++++++++++++++--- 1 file changed, 95 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/test-macos-build.yml b/.gitea/workflows/test-macos-build.yml index 0ed54704..bcdcd6a4 100644 --- a/.gitea/workflows/test-macos-build.yml +++ b/.gitea/workflows/test-macos-build.yml @@ -205,18 +205,104 @@ jobs: # Ensure app is in the expected location after notarization APP_PATH="${{ env.APP_PATH }}" - # Execute the DMG creation script - ./scripts/create_dmg.sh "$APP_PATH" "./PackagedReleases" + # Create directories for installer and DMG + mkdir -p "./PackagedReleases" + BUILD_DIR="./PackagedReleases/LuckyWorldInstall" + rm -rf "$BUILD_DIR" 2>/dev/null || true + mkdir -p "$BUILD_DIR" - # Set the custom DMG path - CUSTOM_DMG_PATH="./PackagedReleases/$(basename "$APP_PATH" .app).dmg" + # Copy app and installation script to build directory + echo "Copying app and installation script..." + cp -R "$APP_PATH" "$BUILD_DIR/" + cp "./scripts/install_luckyworld.sh" "$BUILD_DIR/" + chmod +x "$BUILD_DIR/install_luckyworld.sh" + + # Create a simple README file + cat > "$BUILD_DIR/README.txt" << EOF +LuckyWorld Installation +====================== + +1. Double-click "install_luckyworld.sh" to install the application +2. Follow the on-screen instructions + +For support, visit: https://luckyrobots.io +EOF + + # Set the desired DMG path + CUSTOM_DMG_PATH="./PackagedReleases/LuckyWorld-Installer.dmg" + + # Try first with create-dmg if it's available + if command -v create-dmg &> /dev/null; then + echo "Using create-dmg to create DMG file..." + # First attempt: Using create-dmg with no-finder (CI-friendly approach) + set +e # Don't exit on error + create-dmg \ + --volname "LuckyWorld Installer" \ + --window-pos 200 120 \ + --window-size 800 500 \ + --icon-size 128 \ + --icon "LuckyWorld.app" 200 250 \ + --icon "install_luckyworld.sh" 400 250 \ + --icon "README.txt" 600 250 \ + --hide-extension "LuckyWorld.app" \ + --hide-extension "install_luckyworld.sh" \ + --app-drop-link 400 120 \ + --no-internet-enable \ + --skip-jenkins \ + --no-finder \ + "$CUSTOM_DMG_PATH" \ + "$BUILD_DIR" + CREATE_DMG_STATUS=$? + set -e # Re-enable exit on error + + if [ $CREATE_DMG_STATUS -ne 0 ]; then + echo "create-dmg failed, trying with hdiutil as fallback..." + else + echo "create-dmg succeeded!" + fi + else + echo "create-dmg not found, using hdiutil instead." + CREATE_DMG_STATUS=1 + fi + + # Fallback to hdiutil if create-dmg failed or is not available + if [ ! -f "$CUSTOM_DMG_PATH" ] || [ $CREATE_DMG_STATUS -ne 0 ]; then + echo "Creating DMG with hdiutil (direct macOS command)..." + + # Remove old DMG if exists + rm -f "$CUSTOM_DMG_PATH" 2>/dev/null || true + + # Create DMG with hdiutil + hdiutil create \ + -volname "LuckyWorld Installer" \ + -srcfolder "$BUILD_DIR" \ + -ov \ + -format UDZO \ + "$CUSTOM_DMG_PATH" + + if [ $? -ne 0 ]; then + echo "❌ hdiutil DMG creation failed. Providing ZIP as fallback..." + # As a last resort, create a ZIP file + echo "Creating ZIP archive as fallback..." + (cd "./PackagedReleases" && zip -r "LuckyWorld-Installer.zip" "LuckyWorldInstall") + CUSTOM_DMG_PATH="./PackagedReleases/LuckyWorld-Installer.zip" + fi + fi + + # Check if any package was created + if [ -f "$CUSTOM_DMG_PATH" ]; then + echo "✅ Package created successfully: $CUSTOM_DMG_PATH" + echo "Size: $(du -h "$CUSTOM_DMG_PATH" | cut -f1)" + else + echo "❌ Failed to create any package file" + exit 1 + fi + + # Export the path for later steps echo "CUSTOM_DMG_PATH=$CUSTOM_DMG_PATH" >> $GITHUB_ENV - if [ -f "$CUSTOM_DMG_PATH" ]; then - echo "✅ Custom DMG created successfully: $CUSTOM_DMG_PATH" - else - echo "❌ Failed to create custom DMG" - fi + # Clean up build directory + rm -rf "$BUILD_DIR" shell: bash # Upload the custom DMG with installer script