win-exe.yml 18 KB

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