build.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. name: Build
  2. on:
  3. [push]
  4. env:
  5. JAVA_VERSION: 16
  6. defaults:
  7. run:
  8. shell: bash
  9. jobs:
  10. test:
  11. name: Compile and Test
  12. runs-on: ubuntu-latest
  13. if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
  14. steps:
  15. - uses: actions/checkout@v2
  16. - uses: actions/setup-java@v1
  17. with:
  18. java-version: ${{ env.JAVA_VERSION }}
  19. - uses: actions/cache@v2
  20. with:
  21. path: ~/.m2/repository
  22. key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
  23. restore-keys: |
  24. ${{ runner.os }}-maven-
  25. - name: Ensure to use tagged version
  26. run: mvn versions:set -DnewVersion=${GITHUB_REF##*/} # use shell parameter expansion to strip of 'refs/tags'
  27. if: startsWith(github.ref, 'refs/tags/')
  28. - name: Build and Test
  29. run: mvn -B clean install jacoco:report -Pcoverage,dependency-check
  30. - name: Upload code coverage report
  31. id: codacyCoverageReporter
  32. run: bash <(curl -Ls https://coverage.codacy.com/get.sh)
  33. env:
  34. CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
  35. continue-on-error: true
  36. #
  37. # Buildkit
  38. #
  39. buildkit:
  40. name: Build buildkit-${{ matrix.profile }}
  41. needs: test
  42. runs-on: ${{ matrix.os }}
  43. strategy:
  44. fail-fast: true
  45. matrix:
  46. include:
  47. - os: ubuntu-latest
  48. profile: linux
  49. launcher: launcher-linux.sh
  50. - os: windows-latest
  51. profile: win
  52. launcher: launcher-win.bat
  53. - os: macOS-latest
  54. profile: mac
  55. launcher: launcher-mac.sh
  56. steps:
  57. - uses: actions/checkout@v2
  58. - uses: actions/setup-java@v1
  59. with:
  60. java-version: ${{ env.JAVA_VERSION }}
  61. - uses: actions/cache@v2
  62. with:
  63. path: ~/.m2/repository
  64. key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
  65. restore-keys: |
  66. ${{ runner.os }}-maven-
  67. - name: Copy .jar files
  68. run: mvn -B clean package -DskipTests -P${{ matrix.profile }}
  69. - name: Archive buildkit-${{ matrix.profile }}.tar.gz
  70. run: |
  71. cp LICENSE.txt target
  72. cp dist/buildkit/${{ matrix.launcher }} target
  73. cp target/cryptomator-*.jar target/mods
  74. - name: Upload buildkit-${{ matrix.profile }}
  75. uses: actions/upload-artifact@v2
  76. with:
  77. name: buildkit-${{ matrix.profile }}
  78. path: |
  79. target/libs
  80. target/mods
  81. target/LICENSE.txt
  82. target/${{ matrix.launcher }}
  83. if-no-files-found: error
  84. #
  85. # jlink
  86. #
  87. jlink:
  88. name: Create runtime-${{ matrix.profile }}
  89. needs: test
  90. runs-on: ${{ matrix.os }}
  91. strategy:
  92. fail-fast: true
  93. matrix:
  94. include:
  95. - os: ubuntu-latest
  96. profile: linux
  97. - os: windows-latest
  98. profile: win
  99. - os: macOS-latest
  100. profile: mac
  101. steps:
  102. - uses: actions/checkout@v2
  103. - uses: actions/setup-java@v1
  104. with:
  105. java-version: ${{ env.JAVA_VERSION }}
  106. - name: Create Runtime Image
  107. run: >
  108. ${JAVA_HOME}/bin/jlink
  109. --verbose
  110. --output runtime
  111. --module-path "${JAVA_HOME}/jmods"
  112. --add-modules java.base,java.desktop,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility
  113. --no-header-files
  114. --no-man-pages
  115. --strip-debug
  116. --compress=1
  117. - name: Upload runtime-${{ matrix.profile }}
  118. uses: actions/upload-artifact@v2
  119. with:
  120. name: runtime-${{ matrix.profile }}
  121. path: runtime
  122. if-no-files-found: error
  123. #
  124. # Release Metadata
  125. #
  126. metadata:
  127. name: Determine Version Metadata
  128. runs-on: ubuntu-latest
  129. needs: test
  130. outputs:
  131. versionStr: ${{ steps.versions.outputs.versionStr }}
  132. versionNum: ${{ steps.versions.outputs.versionNum }}
  133. revNum: ${{ steps.versions.outputs.revNum }}
  134. steps:
  135. - uses: actions/checkout@v2
  136. with:
  137. fetch-depth: 0
  138. - id: versions
  139. run: |
  140. if [[ $GITHUB_REF == refs/tags/* ]]; then
  141. echo "::set-output name=versionStr::${GITHUB_REF##*/}"
  142. echo "::set-output name=versionNum::${GITHUB_REF##*/}"
  143. else
  144. echo "::set-output name=versionStr::SNAPSHOT"
  145. echo "::set-output name=versionNum::99.0.0"
  146. fi
  147. echo "::set-output name=revNum::`git rev-list --count HEAD`"
  148. #
  149. # Linux AppImage
  150. #
  151. linux-appimage:
  152. name: Build AppImage
  153. runs-on: ubuntu-latest
  154. needs: [buildkit, jlink, metadata]
  155. steps:
  156. - uses: actions/checkout@v2
  157. - name: Download buildkit-linux
  158. uses: actions/download-artifact@v2
  159. with:
  160. name: buildkit-linux
  161. path: Cryptomator.AppDir
  162. - name: Download runtime-linux
  163. uses: actions/download-artifact@v2
  164. with:
  165. name: runtime-linux
  166. path: Cryptomator.AppDir/runtime
  167. - name: Extract libjffi.so # workaround for https://github.com/cryptomator/cryptomator-linux/issues/27
  168. run: |
  169. JFFI_NATIVE_JAR=`ls libs/ | grep -e 'jffi-[1-9]\.[0-9]\{1,2\}.[0-9]\{1,2\}-native.jar'`
  170. ${JAVA_HOME}/bin/jar -xf libs/${JFFI_NATIVE_JAR} /jni/x86_64-Linux/
  171. mv jni/x86_64-Linux/* libs/libjffi.so
  172. working-directory: Cryptomator.AppDir
  173. - name: Patch Cryptomator.AppDir
  174. run: |
  175. cp -r dist/appimage/resources/AppDir/* Cryptomator.AppDir/
  176. chmod +x Cryptomator.AppDir/runtime/bin/java
  177. envsubst '${REVISION_NO}' < dist/appimage/resources/AppDir/bin/cryptomator.sh > Cryptomator.AppDir/bin/cryptomator.sh
  178. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/org.cryptomator.Cryptomator.svg
  179. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/Cryptomator.svg
  180. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/.DirIcon
  181. ln -s usr/share/applications/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/Cryptomator.desktop
  182. ln -s bin/cryptomator.sh Cryptomator.AppDir/AppRun
  183. env:
  184. REVISION_NO: ${{ needs.metadata.outputs.revNum }}
  185. - name: Download AppImageKit
  186. run: |
  187. curl -L https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -o appimagetool.AppImage
  188. chmod +x appimagetool.AppImage
  189. ./appimagetool.AppImage --appimage-extract
  190. - name: Prepare GPG-Agent for signing with key 615D449FE6E6A235
  191. run: |
  192. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  193. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --dry-run --sign Cryptomator.AppDir/AppRun
  194. env:
  195. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  196. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  197. - name: Build AppImage
  198. run: >
  199. ./squashfs-root/AppRun Cryptomator.AppDir cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage
  200. -u 'gh-releases-zsync|cryptomator|cryptomator|latest|cryptomator-*-x86_64.AppImage.zsync'
  201. --sign --sign-key=615D449FE6E6A235 --sign-args="--batch --pinentry-mode loopback"
  202. - name: Create Detached GPG Signature
  203. run: |
  204. gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage
  205. gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.zsync
  206. - name: Upload AppImage
  207. uses: actions/upload-artifact@v2
  208. with:
  209. name: appimage
  210. path: |
  211. cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage
  212. cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.asc
  213. cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.zsync
  214. cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.zsync.asc
  215. if-no-files-found: error
  216. #
  217. # Windows App Dir
  218. #
  219. windows-appdir:
  220. name: Build Windows App Directory
  221. runs-on: windows-latest
  222. needs: [buildkit, jlink, metadata]
  223. steps:
  224. - uses: actions/checkout@v2
  225. - uses: actions/setup-java@v1
  226. with:
  227. java-version: ${{ env.JAVA_VERSION }}
  228. - name: Download buildkit-win
  229. uses: actions/download-artifact@v2
  230. with:
  231. name: buildkit-win
  232. path: buildkit
  233. - name: Download runtime-win
  234. uses: actions/download-artifact@v2
  235. with:
  236. name: runtime-win
  237. path: runtime
  238. - name: Create app directory
  239. run: >
  240. ${JAVA_HOME}/bin/jpackage
  241. --verbose
  242. --type app-image
  243. --runtime-image runtime
  244. --input buildkit/libs
  245. --module-path buildkit/mods
  246. --dest app
  247. --name Cryptomator
  248. --vendor "Skymatic GmbH"
  249. --copyright "(C) 2016 - 2021 Skymatic GmbH"
  250. --app-version "${{ needs.metadata.outputs.versionNum }}.${{ needs.metadata.outputs.revNum }}"
  251. --icon dist/msi/resources/app/Cryptomator.ico
  252. --java-options "-Dfile.encoding=\"utf-8\""
  253. --java-options "-Dcryptomator.logDir=\"~/AppData/Roaming/Cryptomator\""
  254. --java-options "-Dcryptomator.settingsPath=\"~/AppData/Roaming/Cryptomator/settings.json\""
  255. --java-options "-Dcryptomator.ipcPortPath=\"~/AppData/Roaming/Cryptomator/ipcPort.bin\""
  256. --java-options "-Dcryptomator.keychainPath=\"~/AppData/Roaming/Cryptomator/keychain.json\""
  257. --java-options "-Dcryptomator.mountPointsDir=\"~/Cryptomator\""
  258. --java-options "-Dcryptomator.showTrayIcon=true"
  259. --java-options "-Dcryptomator.buildNumber=\"msi-${{ needs.metadata.outputs.revNum }}\""
  260. --java-options "-Xss2m"
  261. --java-options "-Xmx256m"
  262. --module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator
  263. - name: Patch app directory
  264. run: |
  265. cp dist/msi/resources/app/dlls/* app/Cryptomator/
  266. - name: Upload app directory
  267. uses: actions/upload-artifact@v2
  268. with:
  269. name: win-appdir
  270. path: app/Cryptomator
  271. if-no-files-found: error
  272. # release:
  273. # name: Draft a Release on GitHub Releases
  274. # runs-on: ubuntu-latest
  275. # needs: test
  276. # if: startsWith(github.ref, 'refs/tags/') && github.repository == 'cryptomator/cryptomator'
  277. # steps:
  278. # - uses: actions/checkout@v2
  279. # - name: Download buildkit-linux.zip
  280. # uses: actions/download-artifact@v1
  281. # with:
  282. # name: buildkit-linux.zip
  283. # path: .
  284. # - name: Download buildkit-mac.zip
  285. # uses: actions/download-artifact@v1
  286. # with:
  287. # name: buildkit-mac.zip
  288. # path: .
  289. # - name: Download buildkit-win.zip
  290. # uses: actions/download-artifact@v1
  291. # with:
  292. # name: buildkit-win.zip
  293. # path: .
  294. # - name: Create tarball
  295. # run: git archive --prefix="cryptomator-${{ github.ref }}/" -o "cryptomator-${{ github.ref }}.tar.gz" ${{ github.ref }}
  296. # - name: Sign tarball with key 615D449FE6E6A235
  297. # run: |
  298. # echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  299. # echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a "cryptomator-${{ github.ref }}.tar.gz"
  300. # env:
  301. # GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  302. # GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  303. # - name: Create Release
  304. # id: create_release
  305. # uses: actions/create-release@v1
  306. # env:
  307. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  308. # with:
  309. # tag_name: ${{ github.ref }}
  310. # release_name: ${{ github.ref }}
  311. # body: |
  312. # :construction: Work in Progress
  313. # TODO:
  314. # * [ ] add Linux appimage, zsync file and signature file
  315. # * [ ] add Windows installer and signature file
  316. # * [ ] add MacOs disk image and signature file
  317. # ## What's new
  318. # ## Bugfixes
  319. # ## Misc
  320. # ---
  321. # :scroll: A complete list of closed issues is available [here](LINK)
  322. # draft: true
  323. # prerelease: false
  324. # - name: Upload buildkit-linux.zip to GitHub Releases
  325. # uses: actions/upload-release-asset@v1.0.1
  326. # env:
  327. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  328. # with:
  329. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  330. # asset_path: buildkit-linux.zip
  331. # asset_name: buildkit-linux.zip
  332. # asset_content_type: application/zip
  333. # - name: Upload buildkit-mac.zip to GitHub Releases
  334. # uses: actions/upload-release-asset@v1.0.1
  335. # env:
  336. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  337. # with:
  338. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  339. # asset_path: buildkit-mac.zip
  340. # asset_name: buildkit-mac.zip
  341. # asset_content_type: application/zip
  342. # - name: Upload buildkit-win.zip to GitHub Releases
  343. # uses: actions/upload-release-asset@v1.0.1
  344. # env:
  345. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  346. # with:
  347. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  348. # asset_path: buildkit-win.zip
  349. # asset_name: buildkit-win.zip
  350. # asset_content_type: application/zip
  351. # - name: Upload tarball signature to GitHub Releases
  352. # uses: actions/upload-release-asset@v1.0.1
  353. # env:
  354. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  355. # with:
  356. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  357. # asset_path: "cryptomator-${{ github.ref }}.tar.gz.asc"
  358. # asset_name: "cryptomator-${{ github.ref }}.tar.gz.asc"
  359. # asset_content_type: application/octet-stream