| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- name: Build PicView Avalonia on macOS
- on:
- push:
- branches:
- - dev
- pull_request:
- branches:
- - dev
- jobs:
- build:
- runs-on: macos-latest
- steps:
- # Step 1: Checkout the code
- - name: Checkout repository
- uses: actions/checkout@v4
- # Step 2: Setup .NET 9 SDK
- - name: Setup .NET 9 SDK
- uses: actions/setup-dotnet@v4
- with:
- dotnet-version: '9.x'
- # Step 3: Get version from Directory.Build.props using PowerShell
- - name: Get version from Directory.Build.props
- id: get-version
- run: pwsh -File "${{ github.workspace }}/Build/Get-VersionInfo.ps1"
- # Step 4: Build arm64 version
- - name: Build arm64 version
- run: |
- pwsh -File "${{ github.workspace }}/Build/Build Avalonia.MacOS.ps1" `
- -Platform "arm64" `
- -outputPath "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64" `
- -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
-
- APP_PATH="${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app"
-
- # Verify bundle structure
- if [ ! -f "$APP_PATH/Contents/Info.plist" ]; then
- echo "Error: Info.plist not found in the expected location"
- exit 1
- fi
-
- # Sign all dylibs and binaries
- find "$APP_PATH/Contents/MacOS" -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 "$APP_PATH"
- # Step 5: Create DMG for arm64
- - name: Create DMG for arm64
- run: |
- hdiutil create -volname "PicView" -srcfolder "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app" -ov -format UDZO "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64.dmg"
- # Step 6: Upload arm64 artifacts
- - name: Upload arm64 artifacts
- uses: actions/upload-artifact@v4
- with:
- name: PicView-v${{steps.get-version.outputs.version}}-macOS-arm64
- path: |
- ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app
- ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64.dmg
- retention-days: 14
- # Step 7: Build and create x64 .app bundle
- - name: Build x64 version
- run: |
- pwsh -File "${{ github.workspace }}/Build/Build Avalonia.MacOS.ps1" `
- -Platform "x64" `
- -outputPath "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64" `
- -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: |
- hdiutil create -volname "PicView" -srcfolder "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app" -ov -format UDZO "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64.dmg"
- # Step 9: Upload x64 artifacts
- - name: Upload x64 artifacts
- uses: actions/upload-artifact@v4
- with:
- name: PicView-v${{steps.get-version.outputs.version}}-macOS-x64
- path: |
- ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app
- ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64.dmg
- retention-days: 14
|