win-exe.yml 19 KB

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