win-exe.yml 19 KB

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