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