mac-dmg.yml 11 KB

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