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