win-exe.yml 18 KB

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