mac-dmg.yml 12 KB

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