mac-dmg.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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 "-Xss5m"
  118. --java-options "-Xmx256m"
  119. --java-options "-Dfile.encoding=\"utf-8\""
  120. --java-options "-Djava.net.useSystemProxies=true"
  121. --java-options "-Dapple.awt.enableTemplateImages=true"
  122. --java-options "-Dsun.java2d.metal=true"
  123. --java-options "-Dcryptomator.appVersion=\"${{ needs.get-version.outputs.semVerStr }}\""
  124. --java-options "-Dcryptomator.logDir=\"@{userhome}/Library/Logs/Cryptomator\""
  125. --java-options "-Dcryptomator.pluginDir=\"@{userhome}/Library/Application Support/Cryptomator/Plugins\""
  126. --java-options "-Dcryptomator.settingsPath=\"@{userhome}/Library/Application Support/Cryptomator/settings.json\""
  127. --java-options "-Dcryptomator.p12Path=\"@{userhome}/Library/Application Support/Cryptomator/key.p12\""
  128. --java-options "-Dcryptomator.ipcSocketPath=\"@{userhome}/Library/Application Support/Cryptomator/ipc.socket\""
  129. --java-options "-Dcryptomator.integrationsMac.keychainServiceName=\"Cryptomator\""
  130. --java-options "-Dcryptomator.mountPointsDir=\"@{userhome}/Library/Application Support/Cryptomator/mnt\""
  131. --java-options "-Dcryptomator.showTrayIcon=true"
  132. --java-options "-Dcryptomator.buildNumber=\"dmg-${{ needs.get-version.outputs.revNum }}\""
  133. --mac-package-identifier org.cryptomator
  134. --resource-dir dist/mac/resources
  135. - name: Patch Cryptomator.app
  136. run: |
  137. mv appdir/Cryptomator.app Cryptomator.app
  138. mv dist/mac/resources/Cryptomator-Vault.icns Cryptomator.app/Contents/Resources/
  139. sed -i '' "s|###BUNDLE_SHORT_VERSION_STRING###|${VERSION_NO}|g" Cryptomator.app/Contents/Info.plist
  140. sed -i '' "s|###BUNDLE_VERSION###|${REVISION_NO}|g" Cryptomator.app/Contents/Info.plist
  141. echo -n "$PROVISIONING_PROFILE_BASE64" | base64 --decode --output Cryptomator.app/Contents/embedded.provisionprofile
  142. env:
  143. VERSION_NO: ${{ needs.get-version.outputs.semVerNum }}
  144. REVISION_NO: ${{ needs.get-version.outputs.revNum }}
  145. PROVISIONING_PROFILE_BASE64: ${{ secrets.MACOS_PROVISIONING_PROFILE_BASE64 }}
  146. - name: Generate license for dmg
  147. run: >
  148. mvn -B -Djavafx.platform=mac license:add-third-party
  149. -Dlicense.thirdPartyFilename=license.rtf
  150. -Dlicense.outputDirectory=dist/mac/dmg/resources
  151. -Dlicense.fileTemplate=dist/mac/dmg/resources/licenseTemplate.ftl
  152. -Dlicense.includedScopes=compile
  153. -Dlicense.excludedGroups=^org\.cryptomator
  154. -Dlicense.failOnMissing=true
  155. -Dlicense.licenseMergesUrl=file://${{ github.workspace }}/license/merges
  156. - name: Install codesign certificate
  157. run: |
  158. # create variables
  159. CERTIFICATE_PATH=$RUNNER_TEMP/codesign.p12
  160. KEYCHAIN_PATH=$RUNNER_TEMP/codesign.keychain-db
  161. # import certificate and provisioning profile from secrets
  162. echo -n "$CODESIGN_P12_BASE64" | base64 --decode --output $CERTIFICATE_PATH
  163. # create temporary keychain
  164. security create-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  165. security set-keychain-settings -lut 900 $KEYCHAIN_PATH
  166. security unlock-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  167. # import certificate to keychain
  168. security import $CERTIFICATE_PATH -P "$CODESIGN_P12_PW" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
  169. security list-keychain -d user -s $KEYCHAIN_PATH
  170. env:
  171. CODESIGN_P12_BASE64: ${{ secrets.MACOS_CODESIGN_P12_BASE64 }}
  172. CODESIGN_P12_PW: ${{ secrets.MACOS_CODESIGN_P12_PW }}
  173. CODESIGN_TMP_KEYCHAIN_PW: ${{ secrets.MACOS_CODESIGN_TMP_KEYCHAIN_PW }}
  174. - name: Codesign
  175. run: |
  176. echo "Codesigning jdk files..."
  177. find Cryptomator.app/Contents/runtime/Contents/Home/lib/ -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  178. find Cryptomator.app/Contents/runtime/Contents/Home/lib/ \( -name 'jspawnhelper' -o -name 'pauseengine' -o -name 'simengine' \) -exec codesign --force -o runtime -s ${CODESIGN_IDENTITY} {} \;
  179. echo "Codesigning jar contents..."
  180. find Cryptomator.app/Contents/runtime/Contents/MacOS -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  181. for JAR_PATH in `find Cryptomator.app -name "*.jar"`; do
  182. if [[ `unzip -l ${JAR_PATH} | grep '.dylib\|.jnilib'` ]]; then
  183. JAR_FILENAME=$(basename ${JAR_PATH})
  184. OUTPUT_PATH=${JAR_PATH%.*}
  185. echo "Codesigning libs in ${JAR_FILENAME}..."
  186. unzip -q ${JAR_PATH} -d ${OUTPUT_PATH}
  187. find ${OUTPUT_PATH} -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  188. find ${OUTPUT_PATH} -name '*.jnilib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  189. rm ${JAR_PATH}
  190. pushd ${OUTPUT_PATH} > /dev/null
  191. zip -qr ../${JAR_FILENAME} *
  192. popd > /dev/null
  193. rm -r ${OUTPUT_PATH}
  194. fi
  195. done
  196. echo "Codesigning Cryptomator.app..."
  197. sed -i '' "s|###APP_IDENTIFIER_PREFIX###|${TEAM_IDENTIFIER}.|g" dist/mac/Cryptomator.entitlements
  198. sed -i '' "s|###TEAM_IDENTIFIER###|${TEAM_IDENTIFIER}|g" dist/mac/Cryptomator.entitlements
  199. codesign --force --deep --entitlements dist/mac/Cryptomator.entitlements -o runtime -s ${CODESIGN_IDENTITY} Cryptomator.app
  200. env:
  201. CODESIGN_IDENTITY: ${{ secrets.MACOS_CODESIGN_IDENTITY }}
  202. TEAM_IDENTIFIER: ${{ secrets.MACOS_TEAM_IDENTIFIER }}
  203. - name: Prepare .dmg contents
  204. run: |
  205. mkdir dmg
  206. mv Cryptomator.app dmg
  207. cp dist/mac/dmg/resources/${{ matrix.fuse-lib }}.webloc dmg
  208. ls -l dmg
  209. - name: Install create-dmg
  210. run: |
  211. brew install create-dmg
  212. create-dmg --help
  213. - name: Create .dmg
  214. run: >
  215. create-dmg
  216. --volname Cryptomator
  217. --volicon "dist/mac/dmg/resources/Cryptomator-Volume.icns"
  218. --background "dist/mac/dmg/resources/Cryptomator-${{ matrix.fuse-lib }}-background.tiff"
  219. --window-pos 400 100
  220. --window-size 640 694
  221. --icon-size 128
  222. --icon "Cryptomator.app" 128 245
  223. --hide-extension "Cryptomator.app"
  224. --icon "${{ matrix.fuse-lib }}.webloc" 320 501
  225. --hide-extension "${{ matrix.fuse-lib }}.webloc"
  226. --app-drop-link 512 245
  227. --eula "dist/mac/dmg/resources/license.rtf"
  228. --icon ".background" 128 758
  229. --icon ".VolumeIcon.icns" 512 758
  230. Cryptomator-${VERSION_NO}-${{ matrix.output-suffix }}.dmg dmg
  231. env:
  232. VERSION_NO: ${{ needs.get-version.outputs.semVerNum }}
  233. - name: Notarize .dmg
  234. if: startsWith(github.ref, 'refs/tags/') || inputs.notarize
  235. uses: cocoalibs/xcode-notarization-action@v1
  236. with:
  237. app-path: 'Cryptomator-*.dmg'
  238. apple-id: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
  239. password: ${{ secrets.MACOS_NOTARIZATION_PW }}
  240. team-id: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
  241. xcode-path: '/Applications/Xcode_16.app'
  242. - name: Add possible alpha/beta tags to installer name
  243. run: mv Cryptomator-*.dmg Cryptomator-${{ needs.get-version.outputs.semVerStr }}-${{ matrix.output-suffix }}.dmg
  244. - name: Create detached GPG signature with key 615D449FE6E6A235
  245. run: |
  246. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  247. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.dmg
  248. env:
  249. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  250. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  251. - name: Clean up codesign certificate
  252. if: ${{ always() }}
  253. run: security delete-keychain $RUNNER_TEMP/codesign.keychain-db
  254. continue-on-error: true
  255. - name: Upload artifacts
  256. uses: actions/upload-artifact@v4
  257. with:
  258. name: dmg-${{ matrix.output-suffix }}
  259. path: |
  260. Cryptomator-*.dmg
  261. Cryptomator-*.asc
  262. if-no-files-found: error
  263. - name: Publish dmg on GitHub Releases
  264. if: startsWith(github.ref, 'refs/tags/') && github.event.action == 'published'
  265. uses: softprops/action-gh-release@v2
  266. with:
  267. fail_on_unmatched_files: true
  268. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  269. files: |
  270. Cryptomator-*.dmg
  271. Cryptomator-*.asc