win-exe.yml 18 KB

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