mac-dmg.yml 13 KB

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