win-exe.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. check-latest: true
  43. cache: ${{ env.JAVA_CACHE }}
  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.JFX_JMODS_URL }}"
  48. if(!(Get-FileHash -Path jfxjmods.zip -Algorithm SHA256).Hash.equals("${{ env.JFX_JMODS_HASH }}")) {
  49. throw "Wrong checksum of JMOD archive downloaded from ${{ env.JFX_JMODS_URL }}.";
  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 "-Dcryptomator.logDir=\"~/AppData/Roaming/Cryptomator\""
  110. --java-options "-Dcryptomator.pluginDir=\"~/AppData/Roaming/Cryptomator/Plugins\""
  111. --java-options "-Dcryptomator.settingsPath=\"~/AppData/Roaming/Cryptomator/settings.json\""
  112. --java-options "-Dcryptomator.p12Path=\"~/AppData/Roaming/Cryptomator/key.p12\""
  113. --java-options "-Dcryptomator.ipcSocketPath=\"~/AppData/Roaming/Cryptomator/ipc.socket\""
  114. --java-options "-Dcryptomator.mountPointsDir=\"~/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/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 integrations DLL for code signing
  141. shell: pwsh
  142. run: gci ./appdir/Cryptomator/app/mods/ -File integrations-win-*.jar | ForEach-Object {Set-Location -Path $_.Directory; jar --file=$($_.FullName) --extract integrations.dll }
  143. - name: Codesign
  144. uses: skymatic/code-sign-action@v2
  145. with:
  146. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  147. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  148. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  149. description: Cryptomator
  150. timestampUrl: 'http://timestamp.digicert.com'
  151. folder: appdir/Cryptomator
  152. recursive: true
  153. - name: Repack signed DLL into jar
  154. shell: pwsh
  155. run: |
  156. 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}
  157. - name: Generate license for MSI
  158. run: >
  159. mvn -B license:add-third-party
  160. "-Dlicense.thirdPartyFilename=license.rtf"
  161. "-Dlicense.outputDirectory=dist/win/resources"
  162. "-Dlicense.fileTemplate=dist/win/resources/licenseTemplate.ftl"
  163. "-Dlicense.includedScopes=compile"
  164. "-Dlicense.excludedGroups=^org\.cryptomator"
  165. "-Dlicense.failOnMissing=true"
  166. "-Dlicense.licenseMergesUrl=file:///${{ github.workspace }}/license/merges"
  167. shell: pwsh
  168. - name: Create MSI
  169. run: >
  170. ${JAVA_HOME}/bin/jpackage
  171. --verbose
  172. --type msi
  173. --win-upgrade-uuid bda45523-42b1-4cae-9354-a45475ed4775
  174. --app-image appdir/Cryptomator
  175. --dest installer
  176. --name Cryptomator
  177. --vendor "Skymatic GmbH"
  178. --copyright "(C) 2016 - 2023 Skymatic GmbH"
  179. --app-version "${{ needs.get-version.outputs.semVerNum }}.${{ needs.get-version.outputs.revNum}}"
  180. --win-menu
  181. --win-dir-chooser
  182. --win-shortcut-prompt
  183. --win-update-url "https:\\cryptomator.org"
  184. --win-menu-group Cryptomator
  185. --resource-dir dist/win/resources
  186. --license-file dist/win/resources/license.rtf
  187. --file-associations dist/win/resources/FAvaultFile.properties
  188. env:
  189. JP_WIXWIZARD_RESOURCES: ${{ github.workspace }}/dist/win/resources # requires abs path, used in resources/main.wxs
  190. - name: Codesign MSI
  191. uses: skymatic/code-sign-action@v2
  192. with:
  193. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  194. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  195. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  196. description: Cryptomator Installer
  197. timestampUrl: 'http://timestamp.digicert.com'
  198. folder: installer
  199. - name: Add possible alpha/beta tags to installer name
  200. run: mv installer/Cryptomator-*.msi Cryptomator-${{ needs.get-version.outputs.semVerStr }}-x64.msi
  201. - name: Create detached GPG signature with key 615D449FE6E6A235
  202. run: |
  203. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  204. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.msi
  205. env:
  206. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  207. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  208. - name: Upload artifacts
  209. uses: actions/upload-artifact@v3
  210. with:
  211. name: msi
  212. path: |
  213. Cryptomator-*.msi
  214. Cryptomator-*.asc
  215. if-no-files-found: error
  216. - name: Publish .msi on GitHub Releases
  217. if: startsWith(github.ref, 'refs/tags/')
  218. uses: softprops/action-gh-release@v1
  219. with:
  220. fail_on_unmatched_files: true
  221. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  222. files: |
  223. *.msi
  224. *.asc
  225. build-exe:
  226. name: Build .exe installer
  227. runs-on: windows-latest
  228. needs: [get-version, build-msi]
  229. steps:
  230. - uses: actions/checkout@v3
  231. - name: Download .msi
  232. uses: actions/download-artifact@v3
  233. with:
  234. name: msi
  235. path: dist/win/bundle/resources
  236. - name: Strip version info from msi file name
  237. run: mv dist/win/bundle/resources/Cryptomator*.msi dist/win/bundle/resources/Cryptomator.msi
  238. - uses: actions/setup-java@v3
  239. with:
  240. distribution: ${{ env.JAVA_DIST }}
  241. java-version: ${{ env.JAVA_VERSION }}
  242. check-latest: true
  243. cache: ${{ env.JAVA_CACHE }}
  244. - name: Generate license for exe
  245. run: >
  246. mvn -B license:add-third-party
  247. "-Dlicense.thirdPartyFilename=license.rtf"
  248. "-Dlicense.fileTemplate=dist/win/bundle/resources/licenseTemplate.ftl"
  249. "-Dlicense.outputDirectory=dist/win/bundle/resources"
  250. "-Dlicense.includedScopes=compile"
  251. "-Dlicense.excludedGroups=^org\.cryptomator"
  252. "-Dlicense.failOnMissing=true"
  253. "-Dlicense.licenseMergesUrl=file:///${{ github.workspace }}/license/merges"
  254. shell: pwsh
  255. - name: Download WinFsp
  256. run: |
  257. $winfspUrl = (Select-String -Path ".\dist\win\bundle\resources\winFspMetaData.wxi" -Pattern '<\?define BundledWinFspDownloadLink="(.+)".*?>').Matches.Groups[1].Value
  258. curl --output dist/win/bundle/resources/winfsp.msi -L $winfspUrl
  259. shell: pwsh
  260. - name: Compile to wixObj file
  261. run: >
  262. "${WIX}/bin/candle.exe" dist/win/bundle/bundleWithWinfsp.wxs
  263. -ext WixBalExtension
  264. -ext WixUtilExtension
  265. -out dist/win/bundle/
  266. -dBundleVersion="${{ needs.get-version.outputs.semVerNum }}.${{ needs.get-version.outputs.revNum }}"
  267. -dBundleVendor="Skymatic GmbH"
  268. -dBundleCopyright="(C) 2016 - 2023 Skymatic GmbH"
  269. -dAboutUrl="https://cryptomator.org"
  270. -dHelpUrl="https://cryptomator.org/contact"
  271. -dUpdateUrl="https://cryptomator.org/downloads/"
  272. - name: Create executable with linker
  273. run: >
  274. "${WIX}/bin/light.exe" -b dist/win/ dist/win/bundle/bundleWithWinfsp.wixobj
  275. -ext WixBalExtension
  276. -ext WixUtilExtension
  277. -out installer/unsigned/Cryptomator-Installer.exe
  278. - name: Detach burn engine in preparation to sign
  279. run: >
  280. "${WIX}/bin/insignia.exe"
  281. -ib installer/unsigned/Cryptomator-Installer.exe
  282. -o tmp/engine.exe
  283. - name: Codesign burn engine
  284. uses: skymatic/code-sign-action@v2
  285. with:
  286. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  287. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  288. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  289. description: Cryptomator Installer
  290. timestampUrl: 'http://timestamp.digicert.com'
  291. folder: tmp
  292. - name: Reattach signed burn engine to installer
  293. run : >
  294. "${WIX}/bin/insignia.exe"
  295. -ab tmp/engine.exe installer/unsigned/Cryptomator-Installer.exe
  296. -o installer/Cryptomator-Installer.exe
  297. - name: Codesign EXE
  298. uses: skymatic/code-sign-action@v2
  299. with:
  300. certificate: ${{ secrets.WIN_CODESIGN_P12_BASE64 }}
  301. password: ${{ secrets.WIN_CODESIGN_P12_PW }}
  302. certificatesha1: 5FC94CE149E5B511E621F53A060AC67CBD446B3A
  303. description: Cryptomator Installer
  304. timestampUrl: 'http://timestamp.digicert.com'
  305. folder: installer
  306. - name: Add possible alpha/beta tags to installer name
  307. run: mv installer/Cryptomator-Installer.exe Cryptomator-${{ needs.get-version.outputs.semVerStr }}-x64.exe
  308. - name: Create detached GPG signature with key 615D449FE6E6A235
  309. run: |
  310. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  311. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a Cryptomator-*.exe
  312. env:
  313. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  314. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  315. - name: Upload artifacts
  316. uses: actions/upload-artifact@v3
  317. with:
  318. name: exe
  319. path: |
  320. Cryptomator-*.exe
  321. Cryptomator-*.asc
  322. if-no-files-found: error
  323. - name: Publish .msi on GitHub Releases
  324. if: startsWith(github.ref, 'refs/tags/')
  325. uses: softprops/action-gh-release@v1
  326. with:
  327. fail_on_unmatched_files: true
  328. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  329. files: |
  330. Cryptomator-*.exe
  331. Cryptomator-*.asc
  332. allowlist:
  333. name: Anti Virus Allowlisting
  334. if: startsWith(github.ref, 'refs/tags/')
  335. runs-on: ubuntu-latest
  336. needs: [build-msi, build-exe]
  337. steps:
  338. - name: Download .msi
  339. uses: actions/download-artifact@v3
  340. with:
  341. name: msi
  342. path: msi
  343. - name: Download .exe
  344. uses: actions/download-artifact@v3
  345. with:
  346. name: exe
  347. path: exe
  348. - name: Collect files
  349. run: |
  350. mkdir files
  351. cp msi/*.msi files
  352. cp exe/*.exe files
  353. - name: Upload to Kaspersky
  354. uses: SamKirkland/FTP-Deploy-Action@4.3.3
  355. with:
  356. protocol: ftps
  357. server: allowlist.kaspersky-labs.com
  358. port: 990
  359. username: ${{ secrets.ALLOWLIST_KASPERSKY_USERNAME }}
  360. password: ${{ secrets.ALLOWLIST_KASPERSKY_PASSWORD }}
  361. local-dir: files/
  362. - name: Upload to Avast
  363. uses: SamKirkland/FTP-Deploy-Action@4.3.0
  364. with:
  365. protocol: ftp
  366. server: whitelisting.avast.com
  367. port: 21
  368. username: ${{ secrets.ALLOWLIST_AVAST_USERNAME }}
  369. password: ${{ secrets.ALLOWLIST_AVAST_PASSWORD }}
  370. local-dir: files/