mac-dmg.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. name: Build macOS .dmg
  2. on:
  3. release:
  4. types: [published]
  5. workflow_dispatch:
  6. inputs:
  7. version:
  8. description: 'Version'
  9. required: false
  10. env:
  11. JAVA_VERSION: 20
  12. jobs:
  13. get-version:
  14. uses: ./.github/workflows/get-version.yml
  15. with:
  16. version: ${{ inputs.version }}
  17. build:
  18. name: Build Cryptomator.app for ${{ matrix.output-suffix }}
  19. runs-on: ${{ matrix.os }}
  20. needs: [get-version]
  21. strategy:
  22. fail-fast: false
  23. matrix:
  24. include:
  25. - os: macos-11
  26. architecture: x64
  27. output-suffix: x64
  28. xcode-path: '/Applications/Xcode_13.2.1.app'
  29. fuse-lib: macFUSE
  30. - os: [self-hosted, macOS, ARM64]
  31. architecture: aarch64
  32. output-suffix: arm64
  33. xcode-path: '/Applications/Xcode_13.2.1.app'
  34. fuse-lib: FUSE-T
  35. steps:
  36. - uses: actions/checkout@v3
  37. - name: Setup Java
  38. uses: actions/setup-java@v3
  39. with:
  40. distribution: 'zulu'
  41. java-version: ${{ env.JAVA_VERSION }}
  42. java-package: 'jdk+fx'
  43. architecture: ${{ matrix.architecture }}
  44. cache: 'maven'
  45. - name: Ensure major jfx version in pom equals in jdk
  46. if: ${{ !contains(matrix.os, 'self-hosted') }}
  47. shell: pwsh
  48. run: |
  49. $jfxPomVersion = (&mvn help:evaluate "-Dexpression=javafx.version" -q -DforceStdout) -split "\."
  50. $jfxJdkVersion = ((Get-Content -path "${env:JAVA_HOME}/lib/javafx.properties" | Where-Object {$_ -like 'javafx.version=*' }) -replace '.*=','') -split "\."
  51. if ($jfxPomVersion[0] -ne $jfxJdkVersion[0]) {
  52. Write-Error "Major part of JavaFX version in pom($($jfxPomVersion[0])) does not match the version in JDK($($jfxJdkVersion[0])) "
  53. exit 1
  54. }
  55. - name: Set version
  56. run : mvn versions:set -DnewVersion=${{ needs.get-version.outputs.semVerStr }}
  57. - name: Run maven
  58. run: mvn -B clean package -Pdependency-check,mac -DskipTests
  59. - name: Patch target dir
  60. run: |
  61. cp LICENSE.txt target
  62. cp target/cryptomator-*.jar target/mods
  63. - name: Run jlink
  64. run: >
  65. ${JAVA_HOME}/bin/jlink
  66. --verbose
  67. --output runtime
  68. --module-path "${JAVA_HOME}/jmods"
  69. --add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr
  70. --strip-native-commands
  71. --no-header-files
  72. --no-man-pages
  73. --strip-debug
  74. --compress=1
  75. - name: Run jpackage
  76. run: >
  77. ${JAVA_HOME}/bin/jpackage
  78. --verbose
  79. --type app-image
  80. --runtime-image runtime
  81. --input target/libs
  82. --module-path target/mods
  83. --module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator
  84. --dest appdir
  85. --name Cryptomator
  86. --vendor "Skymatic GmbH"
  87. --copyright "(C) 2016 - 2023 Skymatic GmbH"
  88. --app-version "${{ needs.get-version.outputs.semVerNum }}"
  89. --java-options "--enable-preview"
  90. --java-options "--enable-native-access=org.cryptomator.jfuse.mac"
  91. --java-options "-Xss5m"
  92. --java-options "-Xmx256m"
  93. --java-options "-Dfile.encoding=\"utf-8\""
  94. --java-options "-Dapple.awt.enableTemplateImages=true"
  95. --java-options "-Dsun.java2d.metal=true"
  96. --java-options "-Dcryptomator.appVersion=\"${{ needs.get-version.outputs.semVerStr }}\""
  97. --java-options "-Dcryptomator.logDir=\"~/Library/Logs/Cryptomator\""
  98. --java-options "-Dcryptomator.pluginDir=\"~/Library/Application Support/Cryptomator/Plugins\""
  99. --java-options "-Dcryptomator.settingsPath=\"~/Library/Application Support/Cryptomator/settings.json\""
  100. --java-options "-Dcryptomator.p12Path=\"~/Library/Application Support/Cryptomator/key.p12\""
  101. --java-options "-Dcryptomator.ipcSocketPath=\"~/Library/Application Support/Cryptomator/ipc.socket\""
  102. --java-options "-Dcryptomator.integrationsMac.keychainServiceName=\"Cryptomator\""
  103. --java-options "-Dcryptomator.mountPointsDir=\"~/Cryptomator\""
  104. --java-options "-Dcryptomator.showTrayIcon=true"
  105. --java-options "-Dcryptomator.buildNumber=\"dmg-${{ needs.get-version.outputs.revNum }}\""
  106. --mac-package-identifier org.cryptomator
  107. --resource-dir dist/mac/resources
  108. - name: Patch Cryptomator.app
  109. run: |
  110. mv appdir/Cryptomator.app Cryptomator.app
  111. mv dist/mac/resources/Cryptomator-Vault.icns Cryptomator.app/Contents/Resources/
  112. sed -i '' "s|###BUNDLE_SHORT_VERSION_STRING###|${VERSION_NO}|g" Cryptomator.app/Contents/Info.plist
  113. sed -i '' "s|###BUNDLE_VERSION###|${REVISION_NO}|g" Cryptomator.app/Contents/Info.plist
  114. env:
  115. VERSION_NO: ${{ needs.get-version.outputs.semVerNum }}
  116. REVISION_NO: ${{ needs.get-version.outputs.revNum }}
  117. - name: Generate license for dmg
  118. run: >
  119. mvn -B license:add-third-party
  120. -Dlicense.thirdPartyFilename=license.rtf
  121. -Dlicense.outputDirectory=dist/mac/dmg/resources
  122. -Dlicense.fileTemplate=dist/mac/dmg/resources/licenseTemplate.ftl
  123. -Dlicense.includedScopes=compile
  124. -Dlicense.excludedGroups=^org\.cryptomator
  125. -Dlicense.failOnMissing=true
  126. -Dlicense.licenseMergesUrl=file://${{ github.workspace }}/license/merges
  127. - name: Install codesign certificate
  128. run: |
  129. # create variables
  130. CERTIFICATE_PATH=$RUNNER_TEMP/codesign.p12
  131. KEYCHAIN_PATH=$RUNNER_TEMP/codesign.keychain-db
  132. # import certificate and provisioning profile from secrets
  133. echo -n "$CODESIGN_P12_BASE64" | base64 --decode --output $CERTIFICATE_PATH
  134. # create temporary keychain
  135. security create-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  136. security set-keychain-settings -lut 900 $KEYCHAIN_PATH
  137. security unlock-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  138. # import certificate to keychain
  139. security import $CERTIFICATE_PATH -P "$CODESIGN_P12_PW" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
  140. security list-keychain -d user -s $KEYCHAIN_PATH
  141. env:
  142. CODESIGN_P12_BASE64: ${{ secrets.MACOS_CODESIGN_P12_BASE64 }}
  143. CODESIGN_P12_PW: ${{ secrets.MACOS_CODESIGN_P12_PW }}
  144. CODESIGN_TMP_KEYCHAIN_PW: ${{ secrets.MACOS_CODESIGN_TMP_KEYCHAIN_PW }}
  145. - name: Codesign
  146. run: |
  147. echo "Codesigning jdk files..."
  148. find Cryptomator.app/Contents/runtime/Contents/Home/lib/ -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  149. find Cryptomator.app/Contents/runtime/Contents/Home/lib/ -name 'jspawnhelper' -exec codesign --force -o runtime -s ${CODESIGN_IDENTITY} {} \;
  150. echo "Codesigning jar contents..."
  151. find Cryptomator.app/Contents/runtime/Contents/MacOS -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  152. for JAR_PATH in `find Cryptomator.app -name "*.jar"`; do
  153. if [[ `unzip -l ${JAR_PATH} | grep '.dylib\|.jnilib'` ]]; then
  154. JAR_FILENAME=$(basename ${JAR_PATH})
  155. OUTPUT_PATH=${JAR_PATH%.*}
  156. echo "Codesigning libs in ${JAR_FILENAME}..."
  157. unzip -q ${JAR_PATH} -d ${OUTPUT_PATH}
  158. find ${OUTPUT_PATH} -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  159. find ${OUTPUT_PATH} -name '*.jnilib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  160. rm ${JAR_PATH}
  161. pushd ${OUTPUT_PATH} > /dev/null
  162. zip -qr ../${JAR_FILENAME} *
  163. popd > /dev/null
  164. rm -r ${OUTPUT_PATH}
  165. fi
  166. done
  167. echo "Codesigning Cryptomator.app..."
  168. codesign --force --deep --entitlements dist/mac/Cryptomator.entitlements -o runtime -s ${CODESIGN_IDENTITY} Cryptomator.app
  169. env:
  170. CODESIGN_IDENTITY: ${{ secrets.MACOS_CODESIGN_IDENTITY }}
  171. - name: Prepare .dmg contents
  172. run: |
  173. mkdir dmg
  174. mv Cryptomator.app dmg
  175. cp dist/mac/dmg/resources/${{ matrix.fuse-lib }}.webloc dmg
  176. ls -l dmg
  177. - name: Install create-dmg
  178. run: |
  179. brew install create-dmg
  180. create-dmg --help
  181. - name: Create .dmg
  182. run: >
  183. create-dmg
  184. --volname Cryptomator
  185. --volicon "dist/mac/dmg/resources/Cryptomator-Volume.icns"
  186. --background "dist/mac/dmg/resources/Cryptomator-${{ matrix.fuse-lib }}-background.tiff"
  187. --window-pos 400 100
  188. --window-size 640 694
  189. --icon-size 128
  190. --icon "Cryptomator.app" 128 245
  191. --hide-extension "Cryptomator.app"
  192. --icon "${{ matrix.fuse-lib }}.webloc" 320 501
  193. --hide-extension "${{ matrix.fuse-lib }}.webloc"
  194. --app-drop-link 512 245
  195. --eula "dist/mac/dmg/resources/license.rtf"
  196. --icon ".background" 128 758
  197. --icon ".fseventsd" 320 758
  198. --icon ".VolumeIcon.icns" 512 758
  199. Cryptomator-${VERSION_NO}-${{ matrix.output-suffix }}.dmg dmg
  200. env:
  201. VERSION_NO: ${{ needs.get-version.outputs.semVerNum }}
  202. - name: Notarize .dmg
  203. if: startsWith(github.ref, 'refs/tags/')
  204. uses: cocoalibs/xcode-notarization-action@v1
  205. with:
  206. app-path: 'Cryptomator-*.dmg'
  207. apple-id: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
  208. password: ${{ secrets.MACOS_NOTARIZATION_PW }}
  209. team-id: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
  210. xcode-path: ${{ matrix.xcode-path }}
  211. - name: Add possible alpha/beta tags to installer name
  212. run: mv Cryptomator-*.dmg Cryptomator-${{ needs.get-version.outputs.semVerStr }}-${{ matrix.output-suffix }}.dmg
  213. - name: Create detached GPG signature with key 615D449FE6E6A235
  214. run: |
  215. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  216. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.dmg
  217. env:
  218. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  219. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  220. - name: Clean up codesign certificate
  221. if: ${{ always() }}
  222. run: security delete-keychain $RUNNER_TEMP/codesign.keychain-db
  223. continue-on-error: true
  224. - name: Upload artifacts
  225. uses: actions/upload-artifact@v3
  226. with:
  227. name: dmg-${{ matrix.output-suffix }}
  228. path: Cryptomator-*.dmg
  229. if-no-files-found: error
  230. - name: Publish dmg on GitHub Releases
  231. if: startsWith(github.ref, 'refs/tags/')
  232. uses: softprops/action-gh-release@v1
  233. with:
  234. fail_on_unmatched_files: true
  235. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  236. files: |
  237. Cryptomator-*.dmg
  238. Cryptomator-*.asc