mac-dmg.yml 10 KB

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