win-exe.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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_VERSION: 20
  15. JAVA_DIST: 'temurin'
  16. JAVA_CACHE: 'maven'
  17. JFX_JMODS_URL: 'https://download2.gluonhq.com/openjfx/20.0.1/openjfx-20.0.1_windows-x64_bin-jmods.zip'
  18. JFX_JMODS_HASH: 'D00767334C43B8832B5CF10267D34CA8F563D187C4655B73EB6020DD79C054B5'
  19. defaults:
  20. run:
  21. shell: bash
  22. jobs:
  23. get-version:
  24. uses: ./.github/workflows/get-version.yml
  25. with:
  26. version: ${{ inputs.version }}
  27. build-msi:
  28. name: Build .msi Installer
  29. runs-on: windows-latest
  30. needs: [get-version]
  31. env:
  32. LOOPBACK_ALIAS: 'cryptomator-vault'
  33. WIN_CONSOLE_FLAG: ''
  34. steps:
  35. - uses: actions/checkout@v3
  36. - name: Setup Java
  37. uses: actions/setup-java@v3
  38. with:
  39. distribution: ${{ env.JAVA_DIST }}
  40. java-version: ${{ env.JAVA_VERSION }}
  41. java-package: 'jdk'
  42. cache: ${{ env.JAVA_CACHE }}
  43. - name: Download and extract JavaFX jmods from Gluon
  44. #In the last step we move all jmods files a dir level up because jmods are placed inside a directory in the zip
  45. run: |
  46. curl --output jfxjmods.zip -L "${{ env.JFX_JMODS_URL }}"
  47. if(!(Get-FileHash -Path jfxjmods.zip -Algorithm SHA256).Hash.equals("${{ env.JFX_JMODS_HASH }}")) {
  48. throw "Wrong checksum of JMOD archive downloaded from ${{ env.JFX_JMODS_URL }}.";
  49. }
  50. Expand-Archive -Path jfxjmods.zip -DestinationPath jfxjmods
  51. Get-ChildItem -Path jfxjmods -Recurse -Filter "*.jmod" | ForEach-Object { Move-Item -Path $_ -Destination $_.Directory.Parent}
  52. shell: pwsh
  53. - name: Ensure major jfx version in pom and in jmods is the same
  54. run: |
  55. JMOD_VERSION_AMD64=$(jmod describe jfxjmods/javafx.base.jmod | head -1)
  56. JMOD_VERSION_AMD64=${JMOD_VERSION_AMD64#*@}
  57. JMOD_VERSION_AMD64=${JMOD_VERSION_AMD64%%.*}
  58. POM_JFX_VERSION=$(mvn help:evaluate "-Dexpression=javafx.version" -q -DforceStdout)
  59. POM_JFX_VERSION=${POM_JFX_VERSION#*@}
  60. POM_JFX_VERSION=${POM_JFX_VERSION%%.*}
  61. if [ $POM_JFX_VERSION -ne $JMOD_VERSION_AMD64 ]; then
  62. >&2 echo "Major JavaFX version in pom.xml (${POM_JFX_VERSION}) != amd64 jmod version (${JMOD_VERSION_AMD64})"
  63. exit 1
  64. fi
  65. - name: Set version
  66. run : mvn versions:set -DnewVersion=${{ needs.get-version.outputs.semVerStr }}
  67. - name: Run maven
  68. run: mvn -B clean package -Pdependency-check,win -DskipTests
  69. - name: Patch target dir
  70. run: |
  71. cp LICENSE.txt target
  72. cp target/cryptomator-*.jar target/mods
  73. - name: Run jlink
  74. run: >
  75. ${JAVA_HOME}/bin/jlink
  76. --verbose
  77. --output runtime
  78. --module-path "jfxjmods;${JAVA_HOME}/jmods"
  79. --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
  80. --strip-native-commands
  81. --no-header-files
  82. --no-man-pages
  83. --strip-debug
  84. --compress=1
  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 "-Dcryptomator.logDir=\"~/AppData/Roaming/Cryptomator\""
  109. --java-options "-Dcryptomator.pluginDir=\"~/AppData/Roaming/Cryptomator/Plugins\""
  110. --java-options "-Dcryptomator.settingsPath=\"~/AppData/Roaming/Cryptomator/settings.json\""
  111. --java-options "-Dcryptomator.p12Path=\"~/AppData/Roaming/Cryptomator/key.p12\""
  112. --java-options "-Dcryptomator.ipcSocketPath=\"~/AppData/Roaming/Cryptomator/ipc.socket\""
  113. --java-options "-Dcryptomator.mountPointsDir=\"~/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/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 integrations DLL for code signing
  140. shell: pwsh
  141. run: gci ./appdir/Cryptomator/app/mods/ -File integrations-win-*.jar | ForEach-Object {Set-Location -Path $_.Directory; jar --file=$($_.FullName) --extract integrations.dll }
  142. - name: Codesign
  143. uses: skymatic/code-sign-action@v2
  144. with:
  145. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  146. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  147. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  148. description: Cryptomator
  149. timestampUrl: 'http://timestamp.digicert.com'
  150. folder: appdir/Cryptomator
  151. recursive: true
  152. - name: Repack signed DLL into jar
  153. shell: pwsh
  154. run: |
  155. gci ./appdir/Cryptomator/app/mods/ -File integrations-win-*.jar | ForEach-Object {Set-Location -Path $_.Directory; jar --file=$($_.FullName) --update integrations.dll; Remove-Item integrations.dll}
  156. - name: Generate license for MSI
  157. run: >
  158. mvn -B license:add-third-party
  159. "-Dlicense.thirdPartyFilename=license.rtf"
  160. "-Dlicense.outputDirectory=dist/win/resources"
  161. "-Dlicense.fileTemplate=dist/win/resources/licenseTemplate.ftl"
  162. "-Dlicense.includedScopes=compile"
  163. "-Dlicense.excludedGroups=^org\.cryptomator"
  164. "-Dlicense.failOnMissing=true"
  165. "-Dlicense.licenseMergesUrl=file:///${{ github.workspace }}/license/merges"
  166. shell: pwsh
  167. - name: Create MSI
  168. run: >
  169. ${JAVA_HOME}/bin/jpackage
  170. --verbose
  171. --type msi
  172. --win-upgrade-uuid bda45523-42b1-4cae-9354-a45475ed4775
  173. --app-image appdir/Cryptomator
  174. --dest installer
  175. --name Cryptomator
  176. --vendor "Skymatic GmbH"
  177. --copyright "(C) 2016 - 2023 Skymatic GmbH"
  178. --app-version "${{ needs.get-version.outputs.semVerNum }}.${{ needs.get-version.outputs.revNum}}"
  179. --win-menu
  180. --win-dir-chooser
  181. --win-shortcut-prompt
  182. --win-update-url "https:\\cryptomator.org"
  183. --win-menu-group Cryptomator
  184. --resource-dir dist/win/resources
  185. --license-file dist/win/resources/license.rtf
  186. --file-associations dist/win/resources/FAvaultFile.properties
  187. env:
  188. JP_WIXWIZARD_RESOURCES: ${{ github.workspace }}/dist/win/resources # requires abs path, used in resources/main.wxs
  189. - name: Codesign MSI
  190. uses: skymatic/code-sign-action@v2
  191. with:
  192. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  193. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  194. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  195. description: Cryptomator Installer
  196. timestampUrl: 'http://timestamp.digicert.com'
  197. folder: installer
  198. - name: Add possible alpha/beta tags to installer name
  199. run: mv installer/Cryptomator-*.msi Cryptomator-${{ needs.get-version.outputs.semVerStr }}-x64.msi
  200. - name: Create detached GPG signature with key 615D449FE6E6A235
  201. run: |
  202. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  203. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.msi
  204. env:
  205. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  206. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  207. - name: Upload artifacts
  208. uses: actions/upload-artifact@v3
  209. with:
  210. name: msi
  211. path: |
  212. Cryptomator-*.msi
  213. Cryptomator-*.asc
  214. if-no-files-found: error
  215. - name: Publish .msi on GitHub Releases
  216. if: startsWith(github.ref, 'refs/tags/')
  217. uses: softprops/action-gh-release@v1
  218. with:
  219. fail_on_unmatched_files: true
  220. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  221. files: |
  222. *.msi
  223. *.asc
  224. build-exe:
  225. name: Build .exe installer
  226. runs-on: windows-latest
  227. needs: [get-version, build-msi]
  228. steps:
  229. - uses: actions/checkout@v3
  230. - name: Download .msi
  231. uses: actions/download-artifact@v3
  232. with:
  233. name: msi
  234. path: dist/win/bundle/resources
  235. - name: Strip version info from msi file name
  236. run: mv dist/win/bundle/resources/Cryptomator*.msi dist/win/bundle/resources/Cryptomator.msi
  237. - uses: actions/setup-java@v3
  238. with:
  239. distribution: ${{ env.JAVA_DIST }}
  240. java-version: ${{ env.JAVA_VERSION }}
  241. cache: ${{ env.JAVA_CACHE }}
  242. - name: Generate license for exe
  243. run: >
  244. mvn -B license:add-third-party
  245. "-Dlicense.thirdPartyFilename=license.rtf"
  246. "-Dlicense.fileTemplate=dist/win/bundle/resources/licenseTemplate.ftl"
  247. "-Dlicense.outputDirectory=dist/win/bundle/resources"
  248. "-Dlicense.includedScopes=compile"
  249. "-Dlicense.excludedGroups=^org\.cryptomator"
  250. "-Dlicense.failOnMissing=true"
  251. "-Dlicense.licenseMergesUrl=file:///${{ github.workspace }}/license/merges"
  252. shell: pwsh
  253. - name: Download WinFsp
  254. run: |
  255. $winfspUrl = (Select-String -Path ".\dist\win\bundle\resources\winFspMetaData.wxi" -Pattern '<\?define BundledWinFspDownloadLink="(.+)".*?>').Matches.Groups[1].Value
  256. curl --output dist/win/bundle/resources/winfsp.msi -L $winfspUrl
  257. shell: pwsh
  258. - name: Compile to wixObj file
  259. run: >
  260. "${WIX}/bin/candle.exe" dist/win/bundle/bundleWithWinfsp.wxs
  261. -ext WixBalExtension
  262. -ext WixUtilExtension
  263. -out dist/win/bundle/
  264. -dBundleVersion="${{ needs.get-version.outputs.semVerNum }}.${{ needs.get-version.outputs.revNum }}"
  265. -dBundleVendor="Skymatic GmbH"
  266. -dBundleCopyright="(C) 2016 - 2023 Skymatic GmbH"
  267. -dAboutUrl="https://cryptomator.org"
  268. -dHelpUrl="https://cryptomator.org/contact"
  269. -dUpdateUrl="https://cryptomator.org/downloads/"
  270. - name: Create executable with linker
  271. run: >
  272. "${WIX}/bin/light.exe" -b dist/win/ dist/win/bundle/bundleWithWinfsp.wixobj
  273. -ext WixBalExtension
  274. -ext WixUtilExtension
  275. -out installer/unsigned/Cryptomator-Installer.exe
  276. - name: Detach burn engine in preparation to sign
  277. run: >
  278. "${WIX}/bin/insignia.exe"
  279. -ib installer/unsigned/Cryptomator-Installer.exe
  280. -o tmp/engine.exe
  281. - name: Codesign burn engine
  282. uses: skymatic/code-sign-action@v2
  283. with:
  284. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  285. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  286. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  287. description: Cryptomator Installer
  288. timestampUrl: 'http://timestamp.digicert.com'
  289. folder: tmp
  290. - name: Reattach signed burn engine to installer
  291. run : >
  292. "${WIX}/bin/insignia.exe"
  293. -ab tmp/engine.exe installer/unsigned/Cryptomator-Installer.exe
  294. -o installer/Cryptomator-Installer.exe
  295. - name: Codesign EXE
  296. uses: skymatic/code-sign-action@v2
  297. with:
  298. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  299. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  300. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  301. description: Cryptomator Installer
  302. timestampUrl: 'http://timestamp.digicert.com'
  303. folder: installer
  304. - name: Add possible alpha/beta tags to installer name
  305. run: mv installer/Cryptomator-Installer.exe Cryptomator-${{ needs.get-version.outputs.semVerStr }}-x64.exe
  306. - name: Create detached GPG signature with key 615D449FE6E6A235
  307. run: |
  308. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  309. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.exe
  310. env:
  311. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  312. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  313. - name: Upload artifacts
  314. uses: actions/upload-artifact@v3
  315. with:
  316. name: exe
  317. path: |
  318. Cryptomator-*.exe
  319. Cryptomator-*.asc
  320. if-no-files-found: error
  321. - name: Publish .msi on GitHub Releases
  322. if: startsWith(github.ref, 'refs/tags/')
  323. uses: softprops/action-gh-release@v1
  324. with:
  325. fail_on_unmatched_files: true
  326. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  327. files: |
  328. Cryptomator-*.exe
  329. Cryptomator-*.asc
  330. allowlist:
  331. name: Anti Virus Allowlisting
  332. if: startsWith(github.ref, 'refs/tags/')
  333. runs-on: ubuntu-latest
  334. needs: [build-msi, build-exe]
  335. steps:
  336. - name: Download .msi
  337. uses: actions/download-artifact@v3
  338. with:
  339. name: msi
  340. path: msi
  341. - name: Download .exe
  342. uses: actions/download-artifact@v3
  343. with:
  344. name: exe
  345. path: exe
  346. - name: Collect files
  347. run: |
  348. mkdir files
  349. cp msi/*.msi files
  350. cp exe/*.exe files
  351. - name: Upload to Kaspersky
  352. uses: SamKirkland/FTP-Deploy-Action@4.3.3
  353. with:
  354. protocol: ftps
  355. server: allowlist.kaspersky-labs.com
  356. port: 990
  357. username: ${{ secrets.ALLOWLIST_KASPERSKY_USERNAME }}
  358. password: ${{ secrets.ALLOWLIST_KASPERSKY_PASSWORD }}
  359. local-dir: files/
  360. - name: Upload to Avast
  361. uses: SamKirkland/FTP-Deploy-Action@4.3.0
  362. with:
  363. protocol: ftp
  364. server: whitelisting.avast.com
  365. port: 21
  366. username: ${{ secrets.ALLOWLIST_AVAST_USERNAME }}
  367. password: ${{ secrets.ALLOWLIST_AVAST_PASSWORD }}
  368. local-dir: files/