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_VERSION: 20
  17. jobs:
  18. get-version:
  19. uses: ./.github/workflows/get-version.yml
  20. with:
  21. version: ${{ inputs.version }}
  22. build:
  23. name: Build Cryptomator.app for ${{ matrix.output-suffix }}
  24. runs-on: ${{ matrix.os }}
  25. needs: [get-version]
  26. strategy:
  27. fail-fast: false
  28. matrix:
  29. include:
  30. - os: macos-11
  31. architecture: x64
  32. output-suffix: x64
  33. xcode-path: '/Applications/Xcode_13.2.1.app'
  34. fuse-lib: macFUSE
  35. openjfx-url: https://download2.gluonhq.com/openjfx/20.0.1/openjfx-20.0.1_osx-x64_bin-jmods.zip
  36. openjfx-sha: 4fcd4bc3cd0edeb899108109e42a0c5a2d87d14a195d11199060862eb6d887b5
  37. - os: [self-hosted, macOS, ARM64]
  38. architecture: aarch64
  39. output-suffix: arm64
  40. xcode-path: '/Applications/Xcode_13.2.1.app'
  41. fuse-lib: FUSE-T
  42. openjfx-url: https://download2.gluonhq.com/openjfx/20.0.1/openjfx-20.0.1_osx-aarch64_bin-jmods.zip
  43. openjfx-sha: e7e99e6dc3d091e7e1c6940d8e1acc282f22b82b234a20ae7cbec4b93a6acabe
  44. steps:
  45. - uses: actions/checkout@v3
  46. - name: Setup Java
  47. uses: actions/setup-java@v3
  48. with:
  49. distribution: 'temurin'
  50. java-version: ${{ env.JAVA_VERSION }}
  51. java-package: 'jdk'
  52. architecture: ${{ matrix.architecture }}
  53. cache: 'maven'
  54. - name: Download OpenJFX jmods
  55. id: download-jmods
  56. run: |
  57. curl -L ${{ matrix.openjfx-url }} -o openjfx-jmods.zip
  58. echo "${{ matrix.openjfx-sha }} *openjfx-jmods.zip" | shasum -a256 --check
  59. mkdir -p openjfx-jmods/
  60. unzip -j openjfx-jmods.zip \*/javafx.base.jmod \*/javafx.controls.jmod \*/javafx.fxml.jmod \*/javafx.graphics.jmod -d openjfx-jmods
  61. - name: Ensure major jfx version in pom and in jmods is the same
  62. run: |
  63. JMOD_VERSION=$(jmod describe openjfx-jmods/javafx.base.jmod | head -1)
  64. JMOD_VERSION=${JMOD_VERSION#*@}
  65. JMOD_VERSION=${JMOD_VERSION%%.*}
  66. POM_JFX_VERSION=$(mvn help:evaluate "-Dexpression=javafx.version" -q -DforceStdout)
  67. POM_JFX_VERSION=${POM_JFX_VERSION#*@}
  68. POM_JFX_VERSION=${POM_JFX_VERSION%%.*}
  69. if [ $POM_JFX_VERSION -ne $JMOD_VERSION ]; then
  70. >&2 echo "Major JavaFX version in pom.xml (${POM_JFX_VERSION}) != jmod version (${JMOD_VERSION_AMD64})"
  71. exit 1
  72. fi
  73. - name: Set version
  74. run : mvn versions:set -DnewVersion=${{ needs.get-version.outputs.semVerStr }}
  75. - name: Run maven
  76. run: mvn -B clean package -Pdependency-check,mac -DskipTests
  77. - name: Patch target dir
  78. run: |
  79. cp LICENSE.txt target
  80. cp target/cryptomator-*.jar target/mods
  81. - name: Run jlink
  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.crypto.ec,jdk.accessibility,jdk.management.jfr
  88. --strip-native-commands
  89. --no-header-files
  90. --no-man-pages
  91. --strip-debug
  92. --compress=1
  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 - 2023 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. env:
  134. VERSION_NO: ${{ needs.get-version.outputs.semVerNum }}
  135. REVISION_NO: ${{ needs.get-version.outputs.revNum }}
  136. - name: Generate license for dmg
  137. run: >
  138. mvn -B license:add-third-party
  139. -Dlicense.thirdPartyFilename=license.rtf
  140. -Dlicense.outputDirectory=dist/mac/dmg/resources
  141. -Dlicense.fileTemplate=dist/mac/dmg/resources/licenseTemplate.ftl
  142. -Dlicense.includedScopes=compile
  143. -Dlicense.excludedGroups=^org\.cryptomator
  144. -Dlicense.failOnMissing=true
  145. -Dlicense.licenseMergesUrl=file://${{ github.workspace }}/license/merges
  146. - name: Install codesign certificate
  147. run: |
  148. # create variables
  149. CERTIFICATE_PATH=$RUNNER_TEMP/codesign.p12
  150. KEYCHAIN_PATH=$RUNNER_TEMP/codesign.keychain-db
  151. # import certificate and provisioning profile from secrets
  152. echo -n "$CODESIGN_P12_BASE64" | base64 --decode --output $CERTIFICATE_PATH
  153. # create temporary keychain
  154. security create-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  155. security set-keychain-settings -lut 900 $KEYCHAIN_PATH
  156. security unlock-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  157. # import certificate to keychain
  158. security import $CERTIFICATE_PATH -P "$CODESIGN_P12_PW" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
  159. security list-keychain -d user -s $KEYCHAIN_PATH
  160. env:
  161. CODESIGN_P12_BASE64: ${{ secrets.MACOS_CODESIGN_P12_BASE64 }}
  162. CODESIGN_P12_PW: ${{ secrets.MACOS_CODESIGN_P12_PW }}
  163. CODESIGN_TMP_KEYCHAIN_PW: ${{ secrets.MACOS_CODESIGN_TMP_KEYCHAIN_PW }}
  164. - name: Codesign
  165. run: |
  166. echo "Codesigning jdk files..."
  167. find Cryptomator.app/Contents/runtime/Contents/Home/lib/ -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  168. find Cryptomator.app/Contents/runtime/Contents/Home/lib/ -name 'jspawnhelper' -exec codesign --force -o runtime -s ${CODESIGN_IDENTITY} {} \;
  169. echo "Codesigning jar contents..."
  170. find Cryptomator.app/Contents/runtime/Contents/MacOS -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  171. for JAR_PATH in `find Cryptomator.app -name "*.jar"`; do
  172. if [[ `unzip -l ${JAR_PATH} | grep '.dylib\|.jnilib'` ]]; then
  173. JAR_FILENAME=$(basename ${JAR_PATH})
  174. OUTPUT_PATH=${JAR_PATH%.*}
  175. echo "Codesigning libs in ${JAR_FILENAME}..."
  176. unzip -q ${JAR_PATH} -d ${OUTPUT_PATH}
  177. find ${OUTPUT_PATH} -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  178. find ${OUTPUT_PATH} -name '*.jnilib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  179. rm ${JAR_PATH}
  180. pushd ${OUTPUT_PATH} > /dev/null
  181. zip -qr ../${JAR_FILENAME} *
  182. popd > /dev/null
  183. rm -r ${OUTPUT_PATH}
  184. fi
  185. done
  186. echo "Codesigning Cryptomator.app..."
  187. codesign --force --deep --entitlements dist/mac/Cryptomator.entitlements -o runtime -s ${CODESIGN_IDENTITY} Cryptomator.app
  188. env:
  189. CODESIGN_IDENTITY: ${{ secrets.MACOS_CODESIGN_IDENTITY }}
  190. - name: Prepare .dmg contents
  191. run: |
  192. mkdir dmg
  193. mv Cryptomator.app dmg
  194. cp dist/mac/dmg/resources/${{ matrix.fuse-lib }}.webloc dmg
  195. ls -l dmg
  196. - name: Install create-dmg
  197. run: |
  198. brew install create-dmg
  199. create-dmg --help
  200. - name: Create .dmg
  201. run: >
  202. create-dmg
  203. --volname Cryptomator
  204. --volicon "dist/mac/dmg/resources/Cryptomator-Volume.icns"
  205. --background "dist/mac/dmg/resources/Cryptomator-${{ matrix.fuse-lib }}-background.tiff"
  206. --window-pos 400 100
  207. --window-size 640 694
  208. --icon-size 128
  209. --icon "Cryptomator.app" 128 245
  210. --hide-extension "Cryptomator.app"
  211. --icon "${{ matrix.fuse-lib }}.webloc" 320 501
  212. --hide-extension "${{ matrix.fuse-lib }}.webloc"
  213. --app-drop-link 512 245
  214. --eula "dist/mac/dmg/resources/license.rtf"
  215. --icon ".background" 128 758
  216. --icon ".fseventsd" 320 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