win-exe.yml 19 KB

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