mac-dmg.yml 10 KB

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