mac-dmg.yml 10 KB

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