win-exe.yml 17 KB

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