win-exe.yml 19 KB

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