win-exe.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. - 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
  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.crypto.ec,jdk.accessibility,jdk.management.jfr
  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 - 2024 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"
  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
  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 - 2024 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. - name: Publish .msi on GitHub Releases
  253. if: startsWith(github.ref, 'refs/tags/') && github.event.action == 'published'
  254. uses: softprops/action-gh-release@v1
  255. with:
  256. fail_on_unmatched_files: true
  257. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  258. files: |
  259. *.msi
  260. *.asc
  261. build-exe:
  262. name: Build .exe installer
  263. runs-on: windows-latest
  264. needs: [get-version, build-msi]
  265. steps:
  266. - uses: actions/checkout@v4
  267. - name: Download .msi
  268. uses: actions/download-artifact@v4
  269. with:
  270. name: msi
  271. path: dist/win/bundle/resources
  272. - name: Strip version info from msi file name
  273. run: mv dist/win/bundle/resources/Cryptomator*.msi dist/win/bundle/resources/Cryptomator.msi
  274. - uses: actions/setup-java@v4
  275. with:
  276. distribution: ${{ env.JAVA_DIST }}
  277. java-version: ${{ env.JAVA_VERSION }}
  278. check-latest: true
  279. cache: 'maven'
  280. - name: Generate license for exe
  281. run: >
  282. mvn -B license:add-third-party
  283. "-Dlicense.thirdPartyFilename=license.rtf"
  284. "-Dlicense.fileTemplate=dist/win/bundle/resources/licenseTemplate.ftl"
  285. "-Dlicense.outputDirectory=dist/win/bundle/resources"
  286. "-Dlicense.includedScopes=compile"
  287. "-Dlicense.excludedGroups=^org\.cryptomator"
  288. "-Dlicense.failOnMissing=true"
  289. "-Dlicense.licenseMergesUrl=file:///${{ github.workspace }}/license/merges"
  290. shell: pwsh
  291. - name: Download WinFsp
  292. run: |
  293. curl --output dist/win/bundle/resources/winfsp.msi -L ${{ env.WINFSP_MSI }}
  294. shell: pwsh
  295. - name: Download Legacy-WinFsp uninstaller
  296. run: |
  297. curl --output dist/win/bundle/resources/winfsp-uninstaller.exe -L ${{ env.WINFSP_UNINSTALLER }}
  298. shell: pwsh
  299. - name: Compile to wixObj file
  300. run: >
  301. "${WIX}/bin/candle.exe" dist/win/bundle/bundleWithWinfsp.wxs
  302. -ext WixBalExtension
  303. -ext WixUtilExtension
  304. -out dist/win/bundle/
  305. -dBundleVersion="${{ needs.get-version.outputs.semVerNum }}.${{ needs.get-version.outputs.revNum }}"
  306. -dBundleVendor="Skymatic GmbH"
  307. -dBundleCopyright="(C) 2016 - 2024 Skymatic GmbH"
  308. -dAboutUrl="https://cryptomator.org"
  309. -dHelpUrl="https://cryptomator.org/contact"
  310. -dUpdateUrl="https://cryptomator.org/downloads/"
  311. - name: Create executable with linker
  312. run: >
  313. "${WIX}/bin/light.exe" -b dist/win/ dist/win/bundle/bundleWithWinfsp.wixobj
  314. -ext WixBalExtension
  315. -ext WixUtilExtension
  316. -out installer/unsigned/Cryptomator-Installer.exe
  317. - name: Detach burn engine in preparation to sign
  318. run: >
  319. "${WIX}/bin/insignia.exe"
  320. -ib installer/unsigned/Cryptomator-Installer.exe
  321. -o tmp/engine.exe
  322. - name: Codesign burn engine
  323. uses: skymatic/code-sign-action@v3
  324. with:
  325. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  326. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  327. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  328. description: Cryptomator Installer
  329. timestampUrl: 'http://timestamp.digicert.com'
  330. folder: tmp
  331. - name: Reattach signed burn engine to installer
  332. run : >
  333. "${WIX}/bin/insignia.exe"
  334. -ab tmp/engine.exe installer/unsigned/Cryptomator-Installer.exe
  335. -o installer/Cryptomator-Installer.exe
  336. - name: Codesign EXE
  337. uses: skymatic/code-sign-action@v3
  338. with:
  339. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  340. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  341. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  342. description: Cryptomator Installer
  343. timestampUrl: 'http://timestamp.digicert.com'
  344. folder: installer
  345. - name: Add possible alpha/beta tags to installer name
  346. run: mv installer/Cryptomator-Installer.exe Cryptomator-${{ needs.get-version.outputs.semVerStr }}-x64.exe
  347. - name: Create detached GPG signature with key 615D449FE6E6A235
  348. run: |
  349. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  350. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.exe
  351. env:
  352. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  353. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  354. - name: Upload artifacts
  355. uses: actions/upload-artifact@v4
  356. with:
  357. name: exe
  358. path: |
  359. Cryptomator-*.exe
  360. Cryptomator-*.asc
  361. if-no-files-found: error
  362. - name: Publish .msi on GitHub Releases
  363. if: startsWith(github.ref, 'refs/tags/') && github.event.action == 'published'
  364. uses: softprops/action-gh-release@v1
  365. with:
  366. fail_on_unmatched_files: true
  367. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  368. files: |
  369. Cryptomator-*.exe
  370. Cryptomator-*.asc
  371. allowlist:
  372. name: Anti Virus Allowlisting
  373. if: startsWith(github.ref, 'refs/tags/') && github.event.action == 'published'
  374. runs-on: ubuntu-latest
  375. needs: [build-msi, build-exe]
  376. steps:
  377. - name: Download .msi
  378. uses: actions/download-artifact@v4
  379. with:
  380. name: msi
  381. path: msi
  382. - name: Download .exe
  383. uses: actions/download-artifact@v4
  384. with:
  385. name: exe
  386. path: exe
  387. - name: Collect files
  388. run: |
  389. mkdir files
  390. cp msi/*.msi files
  391. cp exe/*.exe files
  392. - name: Upload to Kaspersky
  393. uses: SamKirkland/FTP-Deploy-Action@v4.3.4
  394. with:
  395. protocol: ftps
  396. server: allowlist.kaspersky-labs.com
  397. port: 990
  398. username: ${{ secrets.ALLOWLIST_KASPERSKY_USERNAME }}
  399. password: ${{ secrets.ALLOWLIST_KASPERSKY_PASSWORD }}
  400. local-dir: files/
  401. - name: Upload to Avast
  402. uses: SamKirkland/FTP-Deploy-Action@v4.3.4
  403. with:
  404. protocol: ftp
  405. server: whitelisting.avast.com
  406. port: 21
  407. username: ${{ secrets.ALLOWLIST_AVAST_USERNAME }}
  408. password: ${{ secrets.ALLOWLIST_AVAST_PASSWORD }}
  409. local-dir: files/
  410. notify-winget:
  411. name: Notify for winget-release
  412. if: startsWith(github.ref, 'refs/tags/') && github.event.action == 'published' && needs.get-version.outputs.versionType == 'stable'
  413. needs: [build-msi, get-version]
  414. runs-on: ubuntu-latest
  415. steps:
  416. - name: Slack Notification
  417. uses: rtCamp/action-slack-notify@v2
  418. env:
  419. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  420. SLACK_USERNAME: 'Cryptobot'
  421. SLACK_ICON: false
  422. SLACK_ICON_EMOJI: ':bot:'
  423. SLACK_CHANNEL: 'cryptomator-desktop'
  424. SLACK_TITLE: "MSI of ${{ github.event.repository.name }} ${{ github.event.release.tag_name }} published."
  425. SLACK_MESSAGE: "Ready to <https://github.com/${{ github.repository }}/actions/workflows/winget.yml| release to winget>."
  426. SLACK_FOOTER: false
  427. MSG_MINIMAL: true