BuildMacOS.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. name: Build PicView Avalonia on macOS
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. pull_request:
  7. branches:
  8. - dev
  9. jobs:
  10. build:
  11. runs-on: macos-latest
  12. steps:
  13. # Step 1: Checkout the code
  14. - name: Checkout repository
  15. uses: actions/checkout@v4
  16. # Step 2: Setup .NET 10 SDK
  17. - name: Setup .NET 10 SDK
  18. uses: actions/setup-dotnet@v5
  19. with:
  20. dotnet-version: '10.x'
  21. # Step 3: Get version from Directory.Build.props using PowerShell
  22. - name: Get version from Directory.Build.props
  23. id: get-version
  24. run: pwsh -File "${{ github.workspace }}/Build/Get-VersionInfo.ps1"
  25. # Step 4: Restore dependencies
  26. - name: Restore dependencies
  27. run: dotnet restore src/PicView.Avalonia.MacOS/PicView.Avalonia.MacOS.csproj
  28. # Step 5: Build arm64 version
  29. - name: Build arm64 version
  30. run: |
  31. pwsh -File "${{ github.workspace }}/Build/Build Avalonia.MacOS.ps1" `
  32. -Platform "arm64" `
  33. -outputPath "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64" `
  34. -appVersion "${{steps.get-version.outputs.version}}"
  35. shell: pwsh
  36. # Add debug step to check the build output directories for arm64
  37. - name: Debug - List build output directories for arm64
  38. run: |
  39. echo "Contents of build output directory:"
  40. ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64"
  41. echo "Contents of .app/Contents/MacOS:"
  42. ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app/Contents/MacOS"
  43. echo "Finding Magick.Native files in the repository:"
  44. find "${{ github.workspace }}" -name "Magick.Native*arm64*.dylib" 2>/dev/null || echo "No Magick.Native arm64 dylib found"
  45. # Add step to ensure Magick.Native libs are in the app bundle for arm64
  46. - name: Copy Magick.Native libraries for arm64
  47. run: |
  48. # Find the Magick.Native dylibs
  49. MAGICK_NATIVE_PATH=$(find "${{ github.workspace }}" -name "Magick.Native*arm64*.dylib" 2>/dev/null || echo "")
  50. if [ ! -z "$MAGICK_NATIVE_PATH" ]; then
  51. echo "Found Magick.Native dylib at: $MAGICK_NATIVE_PATH"
  52. # Copy to the app's MacOS directory
  53. cp "$MAGICK_NATIVE_PATH" "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app/Contents/MacOS/"
  54. # Verify the copy
  55. echo "After copying, MacOS directory contains:"
  56. ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app/Contents/MacOS/"
  57. else
  58. echo "WARNING: Could not find Magick.Native-Q8-arm64.dylib file to copy"
  59. echo "Checking in the nuget cache directory:"
  60. find ~/.nuget -name "Magick.Native*arm64*.dylib" 2>/dev/null || echo "Not found in nuget cache"
  61. fi
  62. # Step 6: Create DMG for arm64
  63. - name: Create DMG for arm64
  64. run: |
  65. 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"
  66. # Step 7: Upload arm64 artifacts
  67. - name: Upload arm64 artifacts
  68. uses: actions/upload-artifact@v4
  69. with:
  70. name: PicView-v${{steps.get-version.outputs.version}}-macOS-arm64
  71. path: |
  72. ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app
  73. ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64.dmg
  74. retention-days: 14
  75. # Step 8: Build x64 version
  76. - name: Build x64 version
  77. run: |
  78. pwsh -File "${{ github.workspace }}/Build/Build Avalonia.MacOS.ps1" `
  79. -Platform "x64" `
  80. -outputPath "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64" `
  81. -appVersion "${{steps.get-version.outputs.version}}"
  82. shell: pwsh
  83. # Add debug step to check the build output directories for x64
  84. - name: Debug - List build output directories for x64
  85. run: |
  86. echo "Contents of build output directory:"
  87. ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64"
  88. echo "Contents of .app/Contents/MacOS:"
  89. ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app/Contents/MacOS"
  90. echo "Finding Magick.Native files in the repository:"
  91. find "${{ github.workspace }}" -name "Magick.Native*x64*.dylib" 2>/dev/null || echo "No Magick.Native x64 dylib found"
  92. # Add step to ensure Magick.Native libs are in the app bundle for x64
  93. - name: Copy Magick.Native libraries for x64
  94. run: |
  95. # Find the Magick.Native dylibs
  96. MAGICK_NATIVE_PATH=$(find "${{ github.workspace }}" -name "Magick.Native*x64*.dylib" 2>/dev/null || echo "")
  97. if [ ! -z "$MAGICK_NATIVE_PATH" ]; then
  98. echo "Found Magick.Native dylib at: $MAGICK_NATIVE_PATH"
  99. # Copy to the app's MacOS directory
  100. cp "$MAGICK_NATIVE_PATH" "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app/Contents/MacOS/"
  101. # Verify the copy
  102. echo "After copying, MacOS directory contains:"
  103. ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app/Contents/MacOS/"
  104. else
  105. echo "WARNING: Could not find Magick.Native-Q8-x64.dylib file to copy"
  106. echo "Checking in the nuget cache directory:"
  107. find ~/.nuget -name "Magick.Native*x64*.dylib" 2>/dev/null || echo "Not found in nuget cache"
  108. fi
  109. # Step 9: Create DMG for x64
  110. - name: Create DMG for x64
  111. run: |
  112. 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"
  113. # Step 10: Upload x64 artifacts
  114. - name: Upload x64 artifacts
  115. uses: actions/upload-artifact@v4
  116. with:
  117. name: PicView-v${{steps.get-version.outputs.version}}-macOS-x64
  118. path: |
  119. ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app
  120. ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64.dmg
  121. retention-days: 14