build.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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: Build 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/${{ 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. # Linux AppImage
  125. #
  126. linux-appimage:
  127. name: Build AppImage
  128. runs-on: ubuntu-latest
  129. needs: [buildkit, jlink]
  130. steps:
  131. - uses: actions/checkout@v2
  132. - name: Set version
  133. id: setversion
  134. run: |
  135. if [[ $GITHUB_REF == refs/tags/* ]]; then
  136. echo "BUILD_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
  137. else
  138. echo "BUILD_VERSION=SNAPSHOT" >> $GITHUB_ENV
  139. fi
  140. - name: Download buildkit-linux
  141. uses: actions/download-artifact@v2
  142. with:
  143. name: buildkit-linux
  144. path: Cryptomator.AppDir
  145. - name: Download runtime-linux
  146. uses: actions/download-artifact@v2
  147. with:
  148. name: runtime-linux
  149. path: Cryptomator.AppDir/runtime
  150. - name: Extract libjffi.so # workaround for https://github.com/cryptomator/cryptomator-linux/issues/27
  151. run: |
  152. JFFI_NATIVE_JAR=`ls libs/ | grep -e 'jffi-[1-9]\.[0-9]\{1,2\}.[0-9]\{1,2\}-native.jar'`
  153. ${JAVA_HOME}/bin/jar -xf libs/${JFFI_NATIVE_JAR} /jni/x86_64-Linux/
  154. mv jni/x86_64-Linux/* libs/libjffi.so
  155. working-directory: Cryptomator.AppDir
  156. - name: Patch Cryptomator.AppDir
  157. run: |
  158. cp -r dist/appimage/resources/appimage/AppDir/* Cryptomator.AppDir/
  159. chmod +x Cryptomator.AppDir/runtime/bin/java
  160. export REVISION_NO=`git rev-list --count HEAD`
  161. envsubst '${REVISION_NO}' < dist/appimage/resources/appimage/AppDir/bin/cryptomator.sh > Cryptomator.AppDir/bin/cryptomator.sh
  162. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/org.cryptomator.Cryptomator.svg
  163. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/Cryptomator.svg
  164. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/.DirIcon
  165. ln -s usr/share/applications/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/Cryptomator.desktop
  166. ln -s bin/cryptomator.sh Cryptomator.AppDir/AppRun
  167. - name: Download AppImageKit
  168. run: |
  169. curl -L https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -o appimagetool.AppImage
  170. chmod +x appimagetool.AppImage
  171. ./appimagetool.AppImage --appimage-extract
  172. - name: Prepare GPG-Agent for signing with key 615D449FE6E6A235
  173. run: |
  174. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  175. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --dry-run --sign Cryptomator.AppDir/AppRun
  176. env:
  177. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  178. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  179. - name: Build AppImage
  180. run: >
  181. ./squashfs-root/AppRun Cryptomator.AppDir cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage
  182. -u 'gh-releases-zsync|cryptomator|cryptomator|latest|cryptomator-*-x86_64.AppImage.zsync'
  183. --sign --sign-key=615D449FE6E6A235 --sign-args="--batch --pinentry-mode loopback"
  184. - name: Create Detached GPG Signature
  185. run: |
  186. gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage
  187. gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage.zsync
  188. - name: Upload AppImage
  189. uses: actions/upload-artifact@v2
  190. with:
  191. name: appimage
  192. path: |
  193. cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage
  194. cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage.asc
  195. cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage.zsync
  196. cryptomator-${{ env.BUILD_VERSION }}-x86_64.AppImage.zsync.asc
  197. if-no-files-found: error
  198. # release:
  199. # name: Draft a Release on GitHub Releases
  200. # runs-on: ubuntu-latest
  201. # needs: test
  202. # if: startsWith(github.ref, 'refs/tags/') && github.repository == 'cryptomator/cryptomator'
  203. # steps:
  204. # - uses: actions/checkout@v2
  205. # - name: Download buildkit-linux.zip
  206. # uses: actions/download-artifact@v1
  207. # with:
  208. # name: buildkit-linux.zip
  209. # path: .
  210. # - name: Download buildkit-mac.zip
  211. # uses: actions/download-artifact@v1
  212. # with:
  213. # name: buildkit-mac.zip
  214. # path: .
  215. # - name: Download buildkit-win.zip
  216. # uses: actions/download-artifact@v1
  217. # with:
  218. # name: buildkit-win.zip
  219. # path: .
  220. # - name: Create tarball
  221. # run: git archive --prefix="cryptomator-${{ github.ref }}/" -o "cryptomator-${{ github.ref }}.tar.gz" ${{ github.ref }}
  222. # - name: Sign tarball with key 615D449FE6E6A235
  223. # run: |
  224. # echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  225. # echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a "cryptomator-${{ github.ref }}.tar.gz"
  226. # env:
  227. # GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  228. # GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  229. # - name: Create Release
  230. # id: create_release
  231. # uses: actions/create-release@v1
  232. # env:
  233. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  234. # with:
  235. # tag_name: ${{ github.ref }}
  236. # release_name: ${{ github.ref }}
  237. # body: |
  238. # :construction: Work in Progress
  239. # TODO:
  240. # * [ ] add Linux appimage, zsync file and signature file
  241. # * [ ] add Windows installer and signature file
  242. # * [ ] add MacOs disk image and signature file
  243. # ## What's new
  244. # ## Bugfixes
  245. # ## Misc
  246. # ---
  247. # :scroll: A complete list of closed issues is available [here](LINK)
  248. # draft: true
  249. # prerelease: false
  250. # - name: Upload buildkit-linux.zip to GitHub Releases
  251. # uses: actions/upload-release-asset@v1.0.1
  252. # env:
  253. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  254. # with:
  255. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  256. # asset_path: buildkit-linux.zip
  257. # asset_name: buildkit-linux.zip
  258. # asset_content_type: application/zip
  259. # - name: Upload buildkit-mac.zip to GitHub Releases
  260. # uses: actions/upload-release-asset@v1.0.1
  261. # env:
  262. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  263. # with:
  264. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  265. # asset_path: buildkit-mac.zip
  266. # asset_name: buildkit-mac.zip
  267. # asset_content_type: application/zip
  268. # - name: Upload buildkit-win.zip to GitHub Releases
  269. # uses: actions/upload-release-asset@v1.0.1
  270. # env:
  271. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  272. # with:
  273. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  274. # asset_path: buildkit-win.zip
  275. # asset_name: buildkit-win.zip
  276. # asset_content_type: application/zip
  277. # - name: Upload tarball signature to GitHub Releases
  278. # uses: actions/upload-release-asset@v1.0.1
  279. # env:
  280. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  281. # with:
  282. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  283. # asset_path: "cryptomator-${{ github.ref }}.tar.gz.asc"
  284. # asset_name: "cryptomator-${{ github.ref }}.tar.gz.asc"
  285. # asset_content_type: application/octet-stream