mac-dmg.yml 13 KB

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