From 5aa43e81d209a6f65adb76159b3725de2330040d Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 28 Sep 2025 02:54:01 -0400 Subject: [PATCH] Refactor macOS packaging process in release workflow and introduce dedicated script - Removed inline macOS packaging logic from release.yml and replaced it with a call to a new script, create-macos-bundle.sh, for better organization and maintainability. - Added create-macos-bundle.sh to handle the creation of the macOS application bundle and DMG file, improving clarity and separation of concerns in the build process. --- .github/workflows/release.yml | 51 ++------------------------- scripts/create-macos-bundle.sh | 64 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 48 deletions(-) create mode 100755 scripts/create-macos-bundle.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index edc33973..653917bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -324,54 +324,9 @@ jobs: cd package && zip -r ../${{ matrix.artifact_name }}.zip * elif [[ "${{ runner.os }}" == "macOS" ]]; then - # macOS packaging - if [ -d "build/bin/yaze.app" ]; then - echo "Found macOS bundle, using it directly" - cp -r build/bin/yaze.app ./Yaze.app - # Add additional resources to the bundle - cp -r assets "Yaze.app/Contents/Resources/" 2>/dev/null || echo "assets directory not found" - # Update Info.plist with correct version - if [ -f "cmake/yaze.plist.in" ]; then - VERSION_NUM=$(echo "${{ needs.validate-and-prepare.outputs.tag_name }}" | sed 's/^v//') - sed "s/@yaze_VERSION@/$VERSION_NUM/g" cmake/yaze.plist.in > "Yaze.app/Contents/Info.plist" - fi - else - echo "No bundle found, creating manual bundle" - mkdir -p "Yaze.app/Contents/MacOS" - mkdir -p "Yaze.app/Contents/Resources" - cp build/bin/yaze "Yaze.app/Contents/MacOS/" - cp -r assets "Yaze.app/Contents/Resources/" 2>/dev/null || echo "assets directory not found" - # Create Info.plist with correct version - VERSION_NUM=$(echo "${{ needs.validate-and-prepare.outputs.tag_name }}" | sed 's/^v//') - cat > "Yaze.app/Contents/Info.plist" < - - - - CFBundleExecutable - yaze - CFBundleIdentifier - com.yaze.editor - CFBundleName - Yaze - CFBundleVersion - $VERSION_NUM - CFBundleShortVersionString - $VERSION_NUM - CFBundlePackageType - APPL - - - EOF - fi - - # Create DMG - mkdir dmg_staging - cp -r Yaze.app dmg_staging/ - cp LICENSE dmg_staging/ 2>/dev/null || echo "LICENSE not found" - cp README.md dmg_staging/ 2>/dev/null || echo "README.md not found" - cp -r docs dmg_staging/ 2>/dev/null || echo "docs directory not found" - hdiutil create -srcfolder dmg_staging -format UDZO -volname "Yaze ${{ needs.validate-and-prepare.outputs.tag_name }}" ${{ matrix.artifact_name }}.dmg + # macOS packaging using dedicated script + VERSION_NUM=$(echo "${{ needs.validate-and-prepare.outputs.tag_name }}" | sed 's/^v//') + ./scripts/create-macos-bundle.sh "$VERSION_NUM" "${{ matrix.artifact_name }}" else # Linux packaging diff --git a/scripts/create-macos-bundle.sh b/scripts/create-macos-bundle.sh new file mode 100755 index 00000000..c35e8fb3 --- /dev/null +++ b/scripts/create-macos-bundle.sh @@ -0,0 +1,64 @@ +#!/bin/bash +set -e + +# Create macOS bundle script +# Usage: create-macos-bundle.sh + +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" + +# macOS packaging +if [ -d "build/bin/yaze.app" ]; then + echo "Found macOS bundle, using it directly" + cp -r build/bin/yaze.app ./Yaze.app + # Add additional resources to the bundle + cp -r assets "Yaze.app/Contents/Resources/" 2>/dev/null || echo "assets directory not found" + # Update Info.plist with correct version + if [ -f "cmake/yaze.plist.in" ]; then + sed "s/@yaze_VERSION@/$VERSION_NUM/g" cmake/yaze.plist.in > "Yaze.app/Contents/Info.plist" + fi +else + echo "No bundle found, creating manual bundle" + mkdir -p "Yaze.app/Contents/MacOS" + mkdir -p "Yaze.app/Contents/Resources" + cp build/bin/yaze "Yaze.app/Contents/MacOS/" + cp -r assets "Yaze.app/Contents/Resources/" 2>/dev/null || echo "assets directory not found" + # Create Info.plist with correct version + cat > "Yaze.app/Contents/Info.plist" < + + + +CFBundleExecutable +yaze +CFBundleIdentifier +com.yaze.editor +CFBundleName +Yaze +CFBundleVersion +$VERSION_NUM +CFBundleShortVersionString +$VERSION_NUM +CFBundlePackageType +APPL + + +EOF +fi + +# Create DMG +mkdir dmg_staging +cp -r Yaze.app dmg_staging/ +cp LICENSE dmg_staging/ 2>/dev/null || echo "LICENSE not found" +cp README.md dmg_staging/ 2>/dev/null || echo "README.md not found" +cp -r docs dmg_staging/ 2>/dev/null || echo "docs directory not found" +hdiutil create -srcfolder dmg_staging -format UDZO -volname "Yaze v$VERSION_NUM" "$ARTIFACT_NAME.dmg" + +echo "macOS bundle creation completed successfully!"