mac-dmg.yml 12 KB

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