win-exe.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. name: Build Windows Installer
  2. on:
  3. release:
  4. types: [published]
  5. workflow_dispatch:
  6. inputs:
  7. version:
  8. description: 'Version'
  9. required: false
  10. isDebug:
  11. description: 'Build debug version with console output'
  12. type: boolean
  13. default: false
  14. env:
  15. JAVA_DIST: 'zulu'
  16. JAVA_VERSION: '24.0.1+9'
  17. OPENJFX_JMODS_AMD64: 'https://download2.gluonhq.com/openjfx/23.0.1/openjfx-23.0.1_windows-x64_bin-jmods.zip'
  18. OPENJFX_JMODS_AMD64_HASH: 'ee176dcee3bd78bde7910735bd67f67c792882f5b89626796ae06f7a1c0119d3'
  19. WINFSP_MSI: 'https://github.com/winfsp/winfsp/releases/download/v2.0/winfsp-2.0.23075.msi'
  20. WINFSP_UNINSTALLER: 'https://github.com/cryptomator/winfsp-uninstaller/releases/latest/download/winfsp-uninstaller.exe'
  21. defaults:
  22. run:
  23. shell: bash
  24. jobs:
  25. get-version:
  26. uses: ./.github/workflows/get-version.yml
  27. with:
  28. version: ${{ inputs.version }}
  29. build-msi:
  30. name: Build .msi Installer
  31. runs-on: windows-latest
  32. needs: [get-version]
  33. env:
  34. LOOPBACK_ALIAS: 'cryptomator-vault'
  35. WIN_CONSOLE_FLAG: ''
  36. steps:
  37. - uses: actions/checkout@v4
  38. - name: Setup Java
  39. uses: actions/setup-java@v4
  40. with:
  41. distribution: ${{ env.JAVA_DIST }}
  42. java-version: ${{ env.JAVA_VERSION }}
  43. check-latest: true
  44. cache: 'maven'
  45. - name: Download and extract JavaFX jmods from Gluon
  46. #In the last step we move all jmods files a dir level up because jmods are placed inside a directory in the zip
  47. run: |
  48. curl --output jfxjmods.zip -L "${{ env.OPENJFX_JMODS_AMD64 }}"
  49. if(!(Get-FileHash -Path jfxjmods.zip -Algorithm SHA256).Hash.ToLower().equals("${{ env.OPENJFX_JMODS_AMD64_HASH }}")) {
  50. throw "Wrong checksum of JMOD archive downloaded from ${{ env.OPENJFX_JMODS_AMD64 }}.";
  51. }
  52. Expand-Archive -Path jfxjmods.zip -DestinationPath jfxjmods
  53. Get-ChildItem -Path jfxjmods -Recurse -Filter "*.jmod" | ForEach-Object { Move-Item -Path $_ -Destination $_.Directory.Parent}
  54. shell: pwsh
  55. - name: Ensure major jfx version in pom and in jmods is the same
  56. run: |
  57. JMOD_VERSION_AMD64=$(jmod describe jfxjmods/javafx.base.jmod | head -1)
  58. JMOD_VERSION_AMD64=${JMOD_VERSION_AMD64#*@}
  59. JMOD_VERSION_AMD64=${JMOD_VERSION_AMD64%%.*}
  60. POM_JFX_VERSION=$(mvn help:evaluate "-Dexpression=javafx.version" -q -DforceStdout)
  61. POM_JFX_VERSION=${POM_JFX_VERSION#*@}
  62. POM_JFX_VERSION=${POM_JFX_VERSION%%.*}
  63. if [ $POM_JFX_VERSION -ne $JMOD_VERSION_AMD64 ]; then
  64. >&2 echo "Major JavaFX version in pom.xml (${POM_JFX_VERSION}) != amd64 jmod version (${JMOD_VERSION_AMD64})"
  65. exit 1
  66. fi
  67. - name: Set version
  68. run : mvn versions:set -DnewVersion=${{ needs.get-version.outputs.semVerStr }}
  69. - name: Run maven
  70. run: mvn -B clean package -Pwin -DskipTests -Djavafx.platform=win
  71. - name: Patch target dir
  72. run: |
  73. cp LICENSE.txt target
  74. cp target/cryptomator-*.jar target/mods
  75. - name: Run jlink with help option
  76. id: jep-493-check
  77. run: |
  78. JMOD_PATHS="openjfx-jmods"
  79. if $(${JAVA_HOME}/bin/jlink --help | grep -o "Linking from run-time image enabled"); then
  80. JMOD_PATHS="${JAVA_HOME}/jmods:${JMOD_PATHS}"
  81. fi
  82. echo "jmod_paths=${JMOD_PATHS}" >> "$GITHUB_OUTPUT"
  83. - name: Run jlink
  84. #Remark: no compression is applied for improved build compression later (here msi)
  85. run: >
  86. ${JAVA_HOME}/bin/jlink
  87. --verbose
  88. --output runtime
  89. --module-path "${{ steps.jep-493-check.outputs.jmod_paths }}"
  90. --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.crypto.mscapi,jdk.unsupported,jdk.accessibility,jdk.management.jfr,java.compiler
  91. --strip-native-commands
  92. --no-header-files
  93. --no-man-pages
  94. --strip-debug
  95. --compress zip-0
  96. - name: Change win-console flag if debug is active
  97. if: ${{ inputs.isDebug }}
  98. run: echo "WIN_CONSOLE_FLAG=--win-console" >> $GITHUB_ENV
  99. - name: Run jpackage
  100. run: >
  101. ${JAVA_HOME}/bin/jpackage
  102. --verbose
  103. --type app-image
  104. --runtime-image runtime
  105. --input target/libs
  106. --module-path target/mods
  107. --module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator
  108. --dest appdir
  109. --name Cryptomator
  110. --vendor "Skymatic GmbH"
  111. --copyright "(C) 2016 - 2025 Skymatic GmbH"
  112. --app-version "${{ needs.get-version.outputs.semVerNum }}.${{ needs.get-version.outputs.revNum }}"
  113. --java-options "--enable-preview"
  114. --java-options "--enable-native-access=org.cryptomator.jfuse.win,org.cryptomator.integrations.win"
  115. --java-options "-Xss5m"
  116. --java-options "-Xmx256m"
  117. --java-options "-Dcryptomator.appVersion=\"${{ needs.get-version.outputs.semVerStr }}\""
  118. --java-options "-Dfile.encoding=\"utf-8\""
  119. --java-options "-Djava.net.useSystemProxies=true"
  120. --java-options "-Dcryptomator.logDir=\"@{localappdata}/Cryptomator\""
  121. --java-options "-Dcryptomator.pluginDir=\"@{appdata}/Cryptomator/Plugins\""
  122. --java-options "-Dcryptomator.settingsPath=\"@{appdata}/Cryptomator/settings.json;@{userhome}/AppData/Roaming/Cryptomator/settings.json\""
  123. --java-options "-Dcryptomator.p12Path=\"@{appdata}/Cryptomator/key.p12;@{userhome}/AppData/Roaming/Cryptomator/key.p12\""
  124. --java-options "-Dcryptomator.ipcSocketPath=\"@{localappdata}/Cryptomator/ipc.socket\""
  125. --java-options "-Dcryptomator.mountPointsDir=\"@{userhome}/Cryptomator\""
  126. --java-options "-Dcryptomator.loopbackAlias=\"${{ env.LOOPBACK_ALIAS }}\""
  127. --java-options "-Dcryptomator.showTrayIcon=true"
  128. --java-options "-Dcryptomator.buildNumber=\"msi-${{ needs.get-version.outputs.revNum }}\""
  129. --java-options "-Dcryptomator.integrationsWin.autoStartShellLinkName=\"Cryptomator\""
  130. --java-options "-Dcryptomator.integrationsWin.keychainPaths=\"@{appdata}/Cryptomator/keychain.json;@{userhome}/AppData/Roaming/Cryptomator/keychain.json\""
  131. --java-options "-Djavafx.verbose=${{ inputs.isDebug }}"
  132. --resource-dir dist/win/resources
  133. --icon dist/win/resources/Cryptomator.ico
  134. ${WIN_CONSOLE_FLAG}
  135. - name: Patch Application Directory
  136. run: |
  137. cp dist/win/contrib/* appdir/Cryptomator
  138. - name: Set LOOPBACK_ALIAS in patchWebDAV.bat
  139. shell: pwsh
  140. run: |
  141. $patchScript = "appdir\Cryptomator\patchWebDAV.bat"
  142. try {
  143. (Get-Content $patchScript ) -replace '::REPLACE ME', "SET LOOPBACK_ALIAS=`"${{ env.LOOPBACK_ALIAS}}`"" | Set-Content $patchScript
  144. } catch {
  145. Write-Host "Failed to set LOOPBACK_ALIAS for patchWebDAV.bat"
  146. exit 1
  147. }
  148. - name: Fix permissions
  149. run: attrib -r appdir/Cryptomator/Cryptomator.exe
  150. shell: pwsh
  151. - name: Extract jars with DLLs for Codesigning
  152. shell: pwsh
  153. run: |
  154. Add-Type -AssemblyName "System.io.compression.filesystem"
  155. $jarFolder = Resolve-Path ".\appdir\Cryptomator\app\mods"
  156. $jarExtractDir = New-Item -Path ".\appdir\jar-extract" -ItemType Directory
  157. #for all jars inspect
  158. Get-ChildItem -Path $jarFolder -Filter "*.jar" | ForEach-Object {
  159. $jar = [Io.compression.zipfile]::OpenRead($_.FullName)
  160. if (@($jar.Entries | Where-Object {$_.Name.ToString().EndsWith(".dll")} | Select-Object -First 1).Count -gt 0) {
  161. #jars containing dlls extract
  162. Set-Location $jarExtractDir
  163. Expand-Archive -Path $_.FullName
  164. }
  165. $jar.Dispose()
  166. }
  167. - name: Extract wixhelper.dll for Codesigning #see https://github.com/cryptomator/cryptomator/issues/3130
  168. shell: pwsh
  169. run: |
  170. New-Item -Path appdir/jpackage-jmod -ItemType Directory
  171. & $env:JAVA_HOME\bin\jmod.exe extract --dir jpackage-jmod "${env:JAVA_HOME}\jmods\jdk.jpackage.jmod"
  172. Get-ChildItem -Recurse -Path "jpackage-jmod" -File wixhelper.dll | Select-Object -Last 1 | Copy-Item -Destination "appdir"
  173. - name: Codesign
  174. uses: skymatic/code-sign-action@v3
  175. with:
  176. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  177. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  178. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  179. description: Cryptomator
  180. timestampUrl: 'http://timestamp.digicert.com'
  181. folder: appdir
  182. recursive: true
  183. - name: Replace DLLs inside jars with signed ones
  184. shell: pwsh
  185. run: |
  186. $jarExtractDir = Resolve-Path ".\appdir\jar-extract"
  187. $jarFolder = Resolve-Path ".\appdir\Cryptomator\app\mods"
  188. Get-ChildItem -Path $jarExtractDir | ForEach-Object {
  189. $jarName = $_.Name
  190. $jarFile = "${jarFolder}\${jarName}.jar"
  191. Set-Location $_
  192. Get-ChildItem -Path $_ -Recurse -File "*.dll" | ForEach-Object {
  193. # update jar with signed dll
  194. jar --file="$jarFile" --update $(Resolve-Path -Relative -Path $_)
  195. }
  196. }
  197. - name: Generate license for MSI
  198. run: >
  199. mvn -B license:add-third-party "-Djavafx.platform=win"
  200. "-Dlicense.thirdPartyFilename=license.rtf"
  201. "-Dlicense.outputDirectory=dist/win/resources"
  202. "-Dlicense.fileTemplate=dist/win/resources/licenseTemplate.ftl"
  203. "-Dlicense.includedScopes=compile"
  204. "-Dlicense.excludedGroups=^org\.cryptomator"
  205. "-Dlicense.failOnMissing=true"
  206. "-Dlicense.licenseMergesUrl=file:///${{ github.workspace }}/license/merges"
  207. shell: pwsh
  208. - name: Create MSI
  209. run: >
  210. ${JAVA_HOME}/bin/jpackage
  211. --verbose
  212. --type msi
  213. --win-upgrade-uuid bda45523-42b1-4cae-9354-a45475ed4775
  214. --app-image appdir/Cryptomator
  215. --dest installer
  216. --name Cryptomator
  217. --vendor "Skymatic GmbH"
  218. --copyright "(C) 2016 - 2025 Skymatic GmbH"
  219. --app-version "${{ needs.get-version.outputs.semVerNum }}.${{ needs.get-version.outputs.revNum}}"
  220. --win-menu
  221. --win-dir-chooser
  222. --win-shortcut-prompt
  223. --win-update-url "https:\\cryptomator.org\downloads"
  224. --win-menu-group Cryptomator
  225. --resource-dir dist/win/resources
  226. --license-file dist/win/resources/license.rtf
  227. --file-associations dist/win/resources/FAvaultFile.properties
  228. env:
  229. JP_WIXWIZARD_RESOURCES: ${{ github.workspace }}/dist/win/resources # requires abs path, used in resources/main.wxs
  230. JP_WIXHELPER_DIR: ${{ github.workspace }}\appdir
  231. - name: Codesign MSI
  232. uses: skymatic/code-sign-action@v3
  233. with:
  234. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  235. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  236. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  237. description: Cryptomator Installer
  238. timestampUrl: 'http://timestamp.digicert.com'
  239. folder: installer
  240. - name: Add possible alpha/beta tags to installer name
  241. run: mv installer/Cryptomator-*.msi Cryptomator-${{ needs.get-version.outputs.semVerStr }}-x64.msi
  242. - name: Create detached GPG signature with key 615D449FE6E6A235
  243. run: |
  244. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  245. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.msi
  246. env:
  247. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  248. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  249. - name: Upload artifacts
  250. uses: actions/upload-artifact@v4
  251. with:
  252. name: msi
  253. path: |
  254. Cryptomator-*.msi
  255. Cryptomator-*.asc
  256. if-no-files-found: error
  257. build-exe:
  258. name: Build .exe installer
  259. runs-on: windows-latest
  260. needs: [get-version, build-msi]
  261. steps:
  262. - uses: actions/checkout@v4
  263. - name: Download .msi
  264. uses: actions/download-artifact@v4
  265. with:
  266. name: msi
  267. path: dist/win/bundle/resources
  268. - name: Strip version info from msi file name
  269. run: mv dist/win/bundle/resources/Cryptomator*.msi dist/win/bundle/resources/Cryptomator.msi
  270. - uses: actions/setup-java@v4
  271. with:
  272. distribution: ${{ env.JAVA_DIST }}
  273. java-version: ${{ env.JAVA_VERSION }}
  274. check-latest: true
  275. cache: 'maven'
  276. - name: Generate license for exe
  277. run: >
  278. mvn -B license:add-third-party "-Djavafx.platform=win"
  279. "-Dlicense.thirdPartyFilename=license.rtf"
  280. "-Dlicense.fileTemplate=dist/win/bundle/resources/licenseTemplate.ftl"
  281. "-Dlicense.outputDirectory=dist/win/bundle/resources"
  282. "-Dlicense.includedScopes=compile"
  283. "-Dlicense.excludedGroups=^org\.cryptomator"
  284. "-Dlicense.failOnMissing=true"
  285. "-Dlicense.licenseMergesUrl=file:///${{ github.workspace }}/license/merges"
  286. shell: pwsh
  287. - name: Download WinFsp
  288. run: |
  289. curl --output dist/win/bundle/resources/winfsp.msi -L ${{ env.WINFSP_MSI }}
  290. shell: pwsh
  291. - name: Download Legacy-WinFsp uninstaller
  292. run: |
  293. curl --output dist/win/bundle/resources/winfsp-uninstaller.exe -L ${{ env.WINFSP_UNINSTALLER }}
  294. shell: pwsh
  295. - name: Compile to wixObj file
  296. run: >
  297. "${WIX}/bin/candle.exe" dist/win/bundle/bundleWithWinfsp.wxs
  298. -ext WixBalExtension
  299. -ext WixUtilExtension
  300. -out dist/win/bundle/
  301. -dBundleVersion="${{ needs.get-version.outputs.semVerNum }}.${{ needs.get-version.outputs.revNum }}"
  302. -dBundleVendor="Skymatic GmbH"
  303. -dBundleCopyright="(C) 2016 - 2025 Skymatic GmbH"
  304. -dAboutUrl="https://cryptomator.org"
  305. -dHelpUrl="https://cryptomator.org/contact"
  306. -dUpdateUrl="https://cryptomator.org/downloads/"
  307. - name: Create executable with linker
  308. run: >
  309. "${WIX}/bin/light.exe" -b dist/win/ dist/win/bundle/bundleWithWinfsp.wixobj
  310. -ext WixBalExtension
  311. -ext WixUtilExtension
  312. -out installer/unsigned/Cryptomator-Installer.exe
  313. - name: Detach burn engine in preparation to sign
  314. run: >
  315. "${WIX}/bin/insignia.exe"
  316. -ib installer/unsigned/Cryptomator-Installer.exe
  317. -o tmp/engine.exe
  318. - name: Codesign burn engine
  319. uses: skymatic/code-sign-action@v3
  320. with:
  321. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  322. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  323. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  324. description: Cryptomator Installer
  325. timestampUrl: 'http://timestamp.digicert.com'
  326. folder: tmp
  327. - name: Reattach signed burn engine to installer
  328. run : >
  329. "${WIX}/bin/insignia.exe"
  330. -ab tmp/engine.exe installer/unsigned/Cryptomator-Installer.exe
  331. -o installer/Cryptomator-Installer.exe
  332. - name: Codesign EXE
  333. uses: skymatic/code-sign-action@v3
  334. with:
  335. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  336. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  337. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  338. description: Cryptomator Installer
  339. timestampUrl: 'http://timestamp.digicert.com'
  340. folder: installer
  341. - name: Add possible alpha/beta tags to installer name
  342. run: mv installer/Cryptomator-Installer.exe Cryptomator-${{ needs.get-version.outputs.semVerStr }}-x64.exe
  343. - name: Create detached GPG signature with key 615D449FE6E6A235
  344. run: |
  345. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  346. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.exe
  347. env:
  348. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  349. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  350. - name: Upload artifacts
  351. uses: actions/upload-artifact@v4
  352. with:
  353. name: exe
  354. path: |
  355. Cryptomator-*.exe
  356. Cryptomator-*.asc
  357. if-no-files-found: error
  358. publish:
  359. name: Publish installers to the github release
  360. if: startsWith(github.ref, 'refs/tags/') && github.event.action == 'published'
  361. runs-on: ubuntu-latest
  362. needs: [build-msi, build-exe]
  363. outputs:
  364. download-url-msi: ${{ fromJSON(steps.publish.outputs.assets)[0].browser_download_url }}
  365. download-url-exe: ${{ fromJSON(steps.publish.outputs.assets)[1].browser_download_url }}
  366. steps:
  367. - name: Download installers
  368. uses: actions/download-artifact@v4
  369. with:
  370. merge-multiple: true
  371. - name: Publish .msi on GitHub Releases
  372. id: publish
  373. uses: softprops/action-gh-release@v2
  374. with:
  375. fail_on_unmatched_files: true
  376. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  377. # do not change ordering of filelist, required for correct job output
  378. files: |
  379. *.msi
  380. *.exe
  381. *.asc
  382. allowlist-msi:
  383. uses: ./.github/workflows/av-whitelist.yml
  384. needs: [publish]
  385. with:
  386. url: ${{ needs.publish.outputs.download-url-msi }}
  387. secrets: inherit
  388. allowlist-exe:
  389. uses: ./.github/workflows/av-whitelist.yml
  390. needs: [publish, allowlist-msi]
  391. with:
  392. url: ${{ needs.publish.outputs.download-url-exe }}
  393. secrets: inherit
  394. notify-winget:
  395. name: Notify for winget-release
  396. if: needs.get-version.outputs.versionType == 'stable'
  397. needs: [publish, get-version]
  398. runs-on: ubuntu-latest
  399. steps:
  400. - name: Slack Notification
  401. uses: rtCamp/action-slack-notify@v2
  402. env:
  403. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  404. SLACK_USERNAME: 'Cryptobot'
  405. SLACK_ICON: false
  406. SLACK_ICON_EMOJI: ':bot:'
  407. SLACK_CHANNEL: 'cryptomator-desktop'
  408. SLACK_TITLE: "MSI of ${{ github.event.repository.name }} ${{ github.event.release.tag_name }} published."
  409. SLACK_MESSAGE: "Ready to <https://github.com/${{ github.repository }}/actions/workflows/winget.yml| release to winget>."
  410. SLACK_FOOTER: false
  411. MSG_MINIMAL: true