mac-dmg.yml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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.instrument,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 "-Dfile.encoding=\"utf-8\""
  83. --java-options "-Dapple.awt.enableTemplateImages=true"
  84. --java-options "-Dsun.java2d.metal=true"
  85. --java-options "-Dcryptomator.appVersion=\"${{ steps.versions.outputs.semVerStr }}\""
  86. --java-options "-Dcryptomator.logDir=\"~/Library/Logs/Cryptomator\""
  87. --java-options "-Dcryptomator.pluginDir=\"~/Library/Application Support/Cryptomator/Plugins\""
  88. --java-options "-Dcryptomator.settingsPath=\"~/Library/Application Support/Cryptomator/settings.json\""
  89. --java-options "-Dcryptomator.p12Path=\"~/Library/Application Support/Cryptomator/key.p12\""
  90. --java-options "-Dcryptomator.ipcSocketPath=\"~/Library/Application Support/Cryptomator/ipc.socket\""
  91. --java-options "-Dcryptomator.integrationsMac.keychainServiceName=\"Cryptomator\""
  92. --java-options "-Dcryptomator.showTrayIcon=true"
  93. --java-options "-Dcryptomator.buildNumber=\"dmg-${{ steps.versions.outputs.revNum }}\""
  94. --mac-package-identifier org.cryptomator
  95. --resource-dir dist/mac/resources
  96. - name: Patch Cryptomator.app
  97. run: |
  98. mv appdir/Cryptomator.app Cryptomator.app
  99. mv dist/mac/resources/Cryptomator-Vault.icns Cryptomator.app/Contents/Resources/
  100. sed -i '' "s|###BUNDLE_SHORT_VERSION_STRING###|${VERSION_NO}|g" Cryptomator.app/Contents/Info.plist
  101. sed -i '' "s|###BUNDLE_VERSION###|${REVISION_NO}|g" Cryptomator.app/Contents/Info.plist
  102. env:
  103. VERSION_NO: ${{ steps.versions.outputs.semVerNum }}
  104. REVISION_NO: ${{ steps.versions.outputs.revNum }}
  105. - name: Generate license for dmg
  106. run: >
  107. mvn -B license:add-third-party
  108. -Dlicense.thirdPartyFilename=license.rtf
  109. -Dlicense.outputDirectory=dist/mac/dmg/resources
  110. -Dlicense.fileTemplate=dist/mac/dmg/resources/licenseTemplate.ftl
  111. -Dlicense.includedScopes=compile
  112. -Dlicense.excludedGroups=^org\.cryptomator
  113. -Dlicense.failOnMissing=true
  114. -Dlicense.licenseMergesUrl=file://${{ github.workspace }}/license/merges
  115. - name: Install codesign certificate
  116. run: |
  117. # create variables
  118. CERTIFICATE_PATH=$RUNNER_TEMP/codesign.p12
  119. KEYCHAIN_PATH=$RUNNER_TEMP/codesign.keychain-db
  120. # import certificate and provisioning profile from secrets
  121. echo -n "$CODESIGN_P12_BASE64" | base64 --decode --output $CERTIFICATE_PATH
  122. # create temporary keychain
  123. security create-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  124. security set-keychain-settings -lut 900 $KEYCHAIN_PATH
  125. security unlock-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  126. # import certificate to keychain
  127. security import $CERTIFICATE_PATH -P "$CODESIGN_P12_PW" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
  128. security list-keychain -d user -s $KEYCHAIN_PATH
  129. env:
  130. CODESIGN_P12_BASE64: ${{ secrets.MACOS_CODESIGN_P12_BASE64 }}
  131. CODESIGN_P12_PW: ${{ secrets.MACOS_CODESIGN_P12_PW }}
  132. CODESIGN_TMP_KEYCHAIN_PW: ${{ secrets.MACOS_CODESIGN_TMP_KEYCHAIN_PW }}
  133. - name: Codesign
  134. run: |
  135. find Cryptomator.app/Contents/runtime/Contents/MacOS -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  136. for JAR_PATH in `find Cryptomator.app -name "*.jar"`; do
  137. if [[ `unzip -l ${JAR_PATH} | grep '.dylib\|.jnilib'` ]]; then
  138. JAR_FILENAME=$(basename ${JAR_PATH})
  139. OUTPUT_PATH=${JAR_PATH%.*}
  140. echo "Codesigning libs in ${JAR_FILENAME}..."
  141. unzip -q ${JAR_PATH} -d ${OUTPUT_PATH}
  142. find ${OUTPUT_PATH} -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  143. find ${OUTPUT_PATH} -name '*.jnilib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  144. rm ${JAR_PATH}
  145. pushd ${OUTPUT_PATH} > /dev/null
  146. zip -qr ../${JAR_FILENAME} *
  147. popd > /dev/null
  148. rm -r ${OUTPUT_PATH}
  149. fi
  150. done
  151. echo "Codesigning Cryptomator.app..."
  152. codesign --force --deep --entitlements dist/mac/Cryptomator.entitlements -o runtime -s ${CODESIGN_IDENTITY} Cryptomator.app
  153. env:
  154. CODESIGN_IDENTITY: ${{ secrets.MACOS_CODESIGN_IDENTITY }}
  155. - name: Prepare .dmg contents
  156. run: |
  157. mkdir dmg
  158. mv Cryptomator.app dmg
  159. cp dist/mac/dmg/resources/macFUSE.webloc dmg
  160. ls -l dmg
  161. - name: Install create-dmg
  162. run: |
  163. brew install create-dmg
  164. create-dmg --help
  165. - name: Create .dmg
  166. run: >
  167. create-dmg
  168. --volname Cryptomator
  169. --volicon "dist/mac/dmg/resources/Cryptomator-Volume.icns"
  170. --background "dist/mac/dmg/resources/Cryptomator-background.tiff"
  171. --window-pos 400 100
  172. --window-size 640 694
  173. --icon-size 128
  174. --icon "Cryptomator.app" 128 245
  175. --hide-extension "Cryptomator.app"
  176. --icon "macFUSE.webloc" 320 501
  177. --hide-extension "macFUSE.webloc"
  178. --app-drop-link 512 245
  179. --eula "dist/mac/dmg/resources/license.rtf"
  180. --icon ".background" 128 758
  181. --icon ".fseventsd" 320 758
  182. --icon ".VolumeIcon.icns" 512 758
  183. Cryptomator-${VERSION_NO}.dmg dmg
  184. env:
  185. VERSION_NO: ${{ steps.versions.outputs.semVerNum }}
  186. - name: Notarize .dmg
  187. if: startsWith(github.ref, 'refs/tags/')
  188. uses: cocoalibs/xcode-notarization-action@v1
  189. with:
  190. app-path: 'Cryptomator-*.dmg'
  191. apple-id: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
  192. password: ${{ secrets.MACOS_NOTARIZATION_PW }}
  193. team-id: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
  194. - name: Add possible alpha/beta tags to installer name
  195. run: mv Cryptomator-*.dmg Cryptomator-${{ steps.versions.outputs.semVerStr }}.dmg
  196. - name: Create detached GPG signature with key 615D449FE6E6A235
  197. run: |
  198. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  199. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.dmg
  200. env:
  201. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  202. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  203. - name: Clean up codesign certificate
  204. if: ${{ always() }}
  205. run: security delete-keychain $RUNNER_TEMP/codesign.keychain-db
  206. continue-on-error: true
  207. - name: Upload artifacts
  208. uses: actions/upload-artifact@v3
  209. with:
  210. name: dmg
  211. path: Cryptomator-*.dmg
  212. if-no-files-found: error
  213. - name: Publish dmg on GitHub Releases
  214. if: startsWith(github.ref, 'refs/tags/')
  215. uses: softprops/action-gh-release@v1
  216. with:
  217. fail_on_unmatched_files: true
  218. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  219. files: |
  220. Cryptomator-*.dmg
  221. Cryptomator-*.asc