mac-dmg.yml 13 KB

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