Parcourir la source

Update build process for macOS

Ruben il y a 9 mois
Parent
commit
e922f2e2c1
2 fichiers modifiés avec 61 ajouts et 8 suppressions
  1. 36 0
      .github/workflows/BuildMacOS.yml
  2. 25 8
      Build/Build Avalonia.MacOS.ps1

+ 36 - 0
.github/workflows/BuildMacOS.yml

@@ -37,6 +37,32 @@ jobs:
             -appVersion "${{steps.get-version.outputs.version}}"
         shell: pwsh
         
+      - name: Prepare and Sign arm64 App Bundle
+        run: |
+          # Create entitlements file
+          cat > entitlements.plist << EOF
+          <?xml version="1.0" encoding="UTF-8"?>
+          <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+          <plist version="1.0">
+          <dict>
+              <key>com.apple.security.cs.allow-jit</key>
+              <true/>
+              <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
+              <true/>
+              <key>com.apple.security.cs.disable-library-validation</key>
+              <true/>
+          </dict>
+          </plist>
+          EOF
+          
+          # Sign all dylibs and binaries
+          find "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app" -type f -name "*.dylib" -o -name "PicView.Avalonia.MacOS" | while read file; do
+            codesign --force --options runtime --sign - --entitlements entitlements.plist "$file"
+          done
+          
+          # Sign the app bundle
+          codesign --force --options runtime --sign - --entitlements entitlements.plist "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app"
+        
       # Step 5: Create DMG for arm64
       - name: Create DMG for arm64
         run: |
@@ -62,6 +88,16 @@ jobs:
             -appVersion "${{steps.get-version.outputs.version}}"
         shell: pwsh
         
+        
+      - name: Prepare and Sign x64 App Bundle
+        run: |
+          find "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app" -type f -name "*.dylib" -o -name "PicView.Avalonia.MacOS" | while read file; do
+            codesign --force --options runtime --sign - --entitlements entitlements.plist "$file"
+          done
+          
+          codesign --force --options runtime --sign - --entitlements entitlements.plist "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app"
+
+        
       # Step 8: Create DMG for x64
       - name: Create DMG for x64
         run: |

+ 25 - 8
Build/Build Avalonia.MacOS.ps1

@@ -76,7 +76,7 @@ $infoPlistContent = @"
     <key>CFBundlePackageType</key>
     <string>APPL</string>
     <key>CFBundleSignature</key>
-    <string>picview.org</string>
+    <string>????</string>
     <key>CFBundleExecutable</key>
     <string>PicView.Avalonia.MacOS</string>
     <key>CFBundleIconFile</key>
@@ -87,18 +87,28 @@ $infoPlistContent = @"
     <string>10.15</string>
     <key>NSHighResolutionCapable</key>
     <true/>
+    <key>LSArchitecturePriority</key>
+    <array>
+        <string>$Platform</string>
+    </array>
+    <key>CFBundleSupportedPlatforms</key>
+    <array>
+        <string>MacOSX</string>
+    </array>
+    <key>NSRequiresAquaSystemAppearance</key>
+    <false/>
 </dict>
 </plist>
 "@
 
-# Save Info.plist
-$infoPlistPath = Join-Path -Path $contentsPath -ChildPath "Info.plist"
-$infoPlistContent | Out-File -FilePath $infoPlistPath -Encoding UTF8
+# Save Info.plist with UTF-8 encoding without BOM
+$utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $false
+[System.IO.File]::WriteAllText($infoPlistPath, $infoPlistContent, $utf8NoBomEncoding)
 
 # Copy build output to MacOS directory
 Copy-Item -Path "$tempBuildPath/*" -Destination $macOSPath -Recurse
 
-# Copy icon if it exists (you'll need to create this)
+# Copy icon if it exists
 $iconSource = Join-Path -Path $PSScriptRoot -ChildPath "../src/PicView.Avalonia.MacOS/Assets/AppIcon.icns"
 if (Test-Path $iconSource) {
     Copy-Item -Path $iconSource -Destination $resourcesPath
@@ -110,8 +120,15 @@ Get-ChildItem -Path $macOSPath -Filter "*.pdb" -Recurse | Remove-Item -Force
 # Remove temporary build directory
 Remove-Item -Path $tempBuildPath -Recurse -Force
 
-# Set executable permissions on the main binary
+# Set proper permissions for the entire .app bundle
 if ($IsLinux -or $IsMacOS) {
-    $mainBinary = Join-Path -Path $macOSPath -ChildPath "PicView.Avalonia.MacOS"
-    chmod +x $mainBinary
+    # Set executable permissions on all binaries and dylibs
+    Get-ChildItem -Path $macOSPath -Recurse | ForEach-Object {
+        if ($_.Extension -in @('.dylib', '') -or $_.Name -eq 'PicView.Avalonia.MacOS') {
+            chmod +x $_.FullName
+        }
+    }
+    
+    # Set proper ownership and permissions for the entire .app bundle
+    chmod -R 755 $appBundlePath
 }