build.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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. - os: windows-latest
  50. profile: win
  51. - os: macos-latest
  52. profile: mac
  53. steps:
  54. - uses: actions/checkout@v2
  55. - uses: actions/setup-java@v1
  56. with:
  57. java-version: ${{ env.JAVA_VERSION }}
  58. - uses: actions/cache@v2
  59. with:
  60. path: ~/.m2/repository
  61. key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
  62. restore-keys: |
  63. ${{ runner.os }}-maven-
  64. - name: Copy .jar files
  65. run: mvn -B clean package -DskipTests -P${{ matrix.profile }}
  66. - name: Archive buildkit-${{ matrix.profile }}.tar.gz
  67. run: |
  68. cp LICENSE.txt target
  69. cp dist/${{ matrix.profile }}/launcher* target
  70. cp target/cryptomator-*.jar target/mods
  71. - name: Upload buildkit-${{ matrix.profile }}
  72. uses: actions/upload-artifact@v2
  73. with:
  74. name: buildkit-${{ matrix.profile }}
  75. path: |
  76. target/libs
  77. target/mods
  78. target/LICENSE.txt
  79. target/${{ matrix.launcher }}
  80. if-no-files-found: error
  81. #
  82. # Release Metadata
  83. #
  84. metadata:
  85. name: Determine Version Metadata
  86. runs-on: ubuntu-latest
  87. needs: test
  88. outputs:
  89. versionStr: ${{ steps.versions.outputs.versionStr }}
  90. versionNum: ${{ steps.versions.outputs.versionNum }}
  91. revNum: ${{ steps.versions.outputs.revNum }}
  92. steps:
  93. - uses: actions/checkout@v2
  94. with:
  95. fetch-depth: 0
  96. - id: versions
  97. run: |
  98. if [[ $GITHUB_REF == refs/tags/* ]]; then
  99. echo "::set-output name=versionStr::${GITHUB_REF##*/}"
  100. echo "::set-output name=versionNum::${GITHUB_REF##*/}"
  101. else
  102. echo "::set-output name=versionStr::SNAPSHOT"
  103. echo "::set-output name=versionNum::99.0.0"
  104. fi
  105. echo "::set-output name=revNum::`git rev-list --count HEAD`"
  106. #
  107. # Application Directory
  108. #
  109. appdir:
  110. name: Create appdir-${{ matrix.profile }}
  111. needs: [buildkit, metadata]
  112. runs-on: ${{ matrix.os }}
  113. strategy:
  114. fail-fast: true
  115. matrix:
  116. include:
  117. - os: ubuntu-latest
  118. profile: linux
  119. jpackageoptions: >
  120. --app-version "${{ needs.metadata.outputs.versionNum }}.${{ needs.metadata.outputs.revNum }}"
  121. --java-options "-Dfile.encoding=\"utf-8\""
  122. --java-options "-Dcryptomator.logDir=\"~/.local/share/Cryptomator/logs\""
  123. --java-options "-Dcryptomator.settingsPath=\"~/.config/Cryptomator/settings.json:~/.Cryptomator/settings.json\""
  124. --java-options "-Dcryptomator.ipcSocketPath=\"~/.config/Cryptomator/ipc.socket\""
  125. --java-options "-Dcryptomator.mountPointsDir=\"~/.local/share/Cryptomator/mnt\""
  126. --java-options "-Dcryptomator.showTrayIcon=false"
  127. --java-options "-Dcryptomator.buildNumber=\"appimage-${{ needs.metadata.outputs.revNum }}\""
  128. --resource-dir dist/linux/resources
  129. - os: windows-latest
  130. profile: win
  131. jpackageoptions: >
  132. --app-version "${{ needs.metadata.outputs.versionNum }}.${{ needs.metadata.outputs.revNum }}"
  133. --java-options "-Dfile.encoding=\"utf-8\""
  134. --java-options "-Dcryptomator.logDir=\"~/AppData/Roaming/Cryptomator\""
  135. --java-options "-Dcryptomator.settingsPath=\"~/AppData/Roaming/Cryptomator/settings.json\""
  136. --java-options "-Dcryptomator.ipcSocketPath=\"~/AppData/Roaming/Cryptomator/ipc.socket\""
  137. --java-options "-Dcryptomator.keychainPath=\"~/AppData/Roaming/Cryptomator/keychain.json\""
  138. --java-options "-Dcryptomator.mountPointsDir=\"~/Cryptomator\""
  139. --java-options "-Dcryptomator.showTrayIcon=true"
  140. --java-options "-Dcryptomator.buildNumber=\"msi-${{ needs.metadata.outputs.revNum }}\""
  141. --resource-dir dist/win/resources
  142. --icon dist/win/resources/Cryptomator.ico
  143. - os: macos-latest
  144. profile: mac
  145. jpackageoptions: >
  146. --app-version "${{ needs.metadata.outputs.versionNum }}"
  147. --java-options "-Dfile.encoding=\"utf-8\""
  148. --java-options "-Dcryptomator.logDir=\"~/Library/Logs/Cryptomator\""
  149. --java-options "-Dcryptomator.settingsPath=\"~/Library/Application Support/Cryptomator/settings.json\""
  150. --java-options "-Dcryptomator.ipcSocketPath=\"~/Library/Application Support/Cryptomator/ipc.socket\""
  151. --java-options "-Dcryptomator.showTrayIcon=true"
  152. --java-options "-Dcryptomator.buildNumber=\"dmg-${{ needs.metadata.outputs.revNum }}\""
  153. --mac-package-identifier org.cryptomator
  154. --resource-dir dist/mac/resources
  155. steps:
  156. - uses: actions/checkout@v2
  157. - uses: actions/setup-java@v1
  158. with:
  159. java-version: ${{ env.JAVA_VERSION }}
  160. - name: Download buildkit-${{ matrix.profile }}
  161. uses: actions/download-artifact@v2
  162. with:
  163. name: buildkit-${{ matrix.profile }}
  164. path: buildkit
  165. - name: Create Runtime Image
  166. run: >
  167. ${JAVA_HOME}/bin/jlink
  168. --verbose
  169. --output runtime
  170. --module-path "${JAVA_HOME}/jmods"
  171. --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
  172. --no-header-files
  173. --no-man-pages
  174. --strip-debug
  175. --compress=1
  176. - name: Create App Directory
  177. run: >
  178. ${JAVA_HOME}/bin/jpackage
  179. --verbose
  180. --type app-image
  181. --runtime-image runtime
  182. --input buildkit/libs
  183. --module-path buildkit/mods
  184. --module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator
  185. --dest appdir
  186. --name Cryptomator
  187. --vendor "Skymatic GmbH"
  188. --copyright "(C) 2016 - 2021 Skymatic GmbH"
  189. --java-options "-Xss5m"
  190. --java-options "-Xmx256m"
  191. ${{ matrix.jpackageoptions }}
  192. - name: Create appdir.tar
  193. run: tar -cvf appdir.tar appdir
  194. # TODO: patch in separate job
  195. # - name: Add Contrib Files
  196. # run: |
  197. # if [ -e dist/appdir/${{ matrix.profile }}/contrib/ ]; then
  198. # cp dist/appdir/${{ matrix.profile }}/contrib/* appdir/
  199. # fi
  200. - name: Upload appdir-${{ matrix.profile }}
  201. uses: actions/upload-artifact@v2
  202. with:
  203. name: appdir-${{ matrix.profile }}
  204. path: appdir.tar
  205. if-no-files-found: error
  206. #
  207. # Linux Cryptomator.AppImage
  208. #
  209. linux-appimage:
  210. name: Build Cryptomator.AppImage
  211. runs-on: ubuntu-latest
  212. needs: [appdir, metadata]
  213. steps:
  214. - uses: actions/checkout@v2
  215. - name: Download appdir-linux
  216. uses: actions/download-artifact@v2
  217. with:
  218. name: appdir-linux
  219. - name: Untar appdir.tar
  220. run: |
  221. tar -xvf appdir.tar
  222. - name: Patch Cryptomator.AppDir
  223. run: |
  224. mv appdir/Cryptomator Cryptomator.AppDir
  225. cp -r dist/linux/appimage/resources/AppDir/* Cryptomator.AppDir/
  226. envsubst '${REVISION_NO}' < dist/linux/appimage/resources/AppDir/bin/cryptomator.sh > Cryptomator.AppDir/bin/cryptomator.sh
  227. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/org.cryptomator.Cryptomator.svg
  228. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/Cryptomator.svg
  229. ln -s usr/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg Cryptomator.AppDir/.DirIcon
  230. ln -s usr/share/applications/org.cryptomator.Cryptomator.desktop Cryptomator.AppDir/Cryptomator.desktop
  231. ln -s bin/cryptomator.sh Cryptomator.AppDir/AppRun
  232. env:
  233. REVISION_NO: ${{ needs.metadata.outputs.revNum }}
  234. - name: Extract libjffi.so # workaround for https://github.com/cryptomator/cryptomator-linux/issues/27
  235. run: |
  236. JFFI_NATIVE_JAR=`ls lib/app/ | grep -e 'jffi-[1-9]\.[0-9]\{1,2\}.[0-9]\{1,2\}-native.jar'`
  237. ${JAVA_HOME}/bin/jar -xf lib/app/${JFFI_NATIVE_JAR} /jni/x86_64-Linux/
  238. mv jni/x86_64-Linux/* lib/app/libjffi.so
  239. working-directory: Cryptomator.AppDir
  240. - name: Download AppImageKit
  241. run: |
  242. curl -L https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -o appimagetool.AppImage
  243. chmod +x appimagetool.AppImage
  244. ./appimagetool.AppImage --appimage-extract
  245. - name: Prepare GPG-Agent for signing with key 615D449FE6E6A235
  246. run: |
  247. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  248. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --dry-run --sign Cryptomator.AppDir/AppRun
  249. env:
  250. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  251. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  252. - name: Build AppImage
  253. run: >
  254. ./squashfs-root/AppRun Cryptomator.AppDir cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage
  255. -u 'gh-releases-zsync|cryptomator|cryptomator|latest|cryptomator-*-x86_64.AppImage.zsync'
  256. --sign --sign-key=615D449FE6E6A235 --sign-args="--batch --pinentry-mode loopback"
  257. - name: Create Detached GPG Signature
  258. run: |
  259. gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage
  260. gpg --batch --quiet --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.zsync
  261. - name: Upload AppImage
  262. uses: actions/upload-artifact@v2
  263. with:
  264. name: appimage
  265. path: |
  266. cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage
  267. cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.asc
  268. cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.zsync
  269. cryptomator-${{ needs.metadata.outputs.versionStr }}-x86_64.AppImage.zsync.asc
  270. if-no-files-found: error
  271. #
  272. # macOS Cryptomator.app
  273. #
  274. mac-app:
  275. name: Build Cryptomator.app
  276. runs-on: macos-latest
  277. needs: [appdir, metadata]
  278. steps:
  279. - uses: actions/checkout@v2
  280. - name: Download appdir-mac
  281. uses: actions/download-artifact@v2
  282. with:
  283. name: appdir-mac
  284. - name: Untar appdir.tar
  285. run: tar -xvf appdir.tar
  286. - name: Patch Cryptomator.app
  287. run: |
  288. mv appdir/Cryptomator.app Cryptomator.app
  289. sed -i '' "s|###BUNDLE_SHORT_VERSION_STRING###|${VERSION_NO}|g" Cryptomator.app/Contents/Info.plist
  290. sed -i '' "s|###BUNDLE_VERSION###|${REVISION_NO}|g" Cryptomator.app/Contents/Info.plist
  291. env:
  292. VERSION_NO: ${{ needs.metadata.outputs.versionNum }}
  293. REVISION_NO: ${{ needs.metadata.outputs.revNum }}
  294. - name: Install codesign certificate
  295. env:
  296. CODESIGN_P12_BASE64: ${{ secrets.MACOS_CODESIGN_P12_BASE64 }}
  297. CODESIGN_P12_PW: ${{ secrets.MACOS_CODESIGN_P12_PW }}
  298. CODESIGN_TMP_KEYCHAIN_PW: ${{ secrets.MACOS_CODESIGN_TMP_KEYCHAIN_PW }}
  299. run: |
  300. # create variables
  301. CERTIFICATE_PATH=$RUNNER_TEMP/codesign.p12
  302. KEYCHAIN_PATH=$RUNNER_TEMP/codesign.keychain-db
  303. # import certificate and provisioning profile from secrets
  304. echo -n "$CODESIGN_P12_BASE64" | base64 --decode --output $CERTIFICATE_PATH
  305. # create temporary keychain
  306. security create-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  307. security set-keychain-settings -lut 900 $KEYCHAIN_PATH
  308. security unlock-keychain -p "$CODESIGN_TMP_KEYCHAIN_PW" $KEYCHAIN_PATH
  309. # import certificate to keychain
  310. security import $CERTIFICATE_PATH -P "$CODESIGN_P12_PW" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
  311. security list-keychain -d user -s $KEYCHAIN_PATH
  312. - name: Codesign
  313. env:
  314. CODESIGN_IDENTITY: ${{ secrets.MACOS_CODESIGN_IDENTITY }}
  315. run: |
  316. find Cryptomator.app/Contents/runtime/Contents/MacOS -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
  317. for JAR_PATH in Cryptomator.app/**/*.jar; do
  318. if [[ `unzip -l ${JAR_PATH} | grep '.dylib\|.jnilib'` ]]; then
  319. JAR_FILENAME=$(basename ${JAR_PATH})
  320. OUTPUT_PATH=${JAR_PATH%.*}
  321. echo "Codesigning libs in ${JAR_FILENAME}..."
  322. unzip -q ${JAR_PATH} -d ${OUTPUT_PATH}
  323. find ${OUTPUT_PATH} -name '*.dylib' -exec codesign -s ${CODESIGN_IDENTITY} {} \;
  324. find ${OUTPUT_PATH} -name '*.jnilib' -exec codesign -s ${CODESIGN_IDENTITY} {} \;
  325. rm ${JAR_PATH}
  326. pushd ${OUTPUT_PATH} > /dev/null
  327. zip -qr ../${JAR_FILENAME} *
  328. popd > /dev/null
  329. rm -r ${OUTPUT_PATH}
  330. fi
  331. done
  332. echo "Codesigning Cryptomator.app..."
  333. codesign --force --deep --entitlements dist/mac/Cryptomator.entitlements -o runtime -s ${CODESIGN_IDENTITY} Cryptomator.app
  334. shell: zsh {0}
  335. - name: Clean up codesign certificate
  336. if: ${{ always() }}
  337. run: security delete-keychain $RUNNER_TEMP/codesign.keychain-db
  338. - name: Create app.tar
  339. run: tar -cvf app.tar Cryptomator.app
  340. - name: Upload appdir-${{ matrix.profile }}
  341. uses: actions/upload-artifact@v2
  342. with:
  343. name: macOS-app
  344. path: app.tar
  345. if-no-files-found: error
  346. # release:
  347. # name: Draft a Release on GitHub Releases
  348. # runs-on: ubuntu-latest
  349. # needs: test
  350. # if: startsWith(github.ref, 'refs/tags/') && github.repository == 'cryptomator/cryptomator'
  351. # steps:
  352. # - uses: actions/checkout@v2
  353. # - name: Download buildkit-linux.zip
  354. # uses: actions/download-artifact@v1
  355. # with:
  356. # name: buildkit-linux.zip
  357. # path: .
  358. # - name: Download buildkit-mac.zip
  359. # uses: actions/download-artifact@v1
  360. # with:
  361. # name: buildkit-mac.zip
  362. # path: .
  363. # - name: Download buildkit-win.zip
  364. # uses: actions/download-artifact@v1
  365. # with:
  366. # name: buildkit-win.zip
  367. # path: .
  368. # - name: Create tarball
  369. # run: git archive --prefix="cryptomator-${{ github.ref }}/" -o "cryptomator-${{ github.ref }}.tar.gz" ${{ github.ref }}
  370. # - name: Sign tarball with key 615D449FE6E6A235
  371. # run: |
  372. # echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  373. # echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a "cryptomator-${{ github.ref }}.tar.gz"
  374. # env:
  375. # GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  376. # GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  377. # - name: Create Release
  378. # id: create_release
  379. # uses: actions/create-release@v1
  380. # env:
  381. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  382. # with:
  383. # tag_name: ${{ github.ref }}
  384. # release_name: ${{ github.ref }}
  385. # body: |
  386. # :construction: Work in Progress
  387. # TODO:
  388. # * [ ] add Linux appimage, zsync file and signature file
  389. # * [ ] add Windows installer and signature file
  390. # * [ ] add MacOs disk image and signature file
  391. # ## What's new
  392. # ## Bugfixes
  393. # ## Misc
  394. # ---
  395. # :scroll: A complete list of closed issues is available [here](LINK)
  396. # draft: true
  397. # prerelease: false
  398. # - name: Upload buildkit-linux.zip to GitHub Releases
  399. # uses: actions/upload-release-asset@v1.0.1
  400. # env:
  401. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  402. # with:
  403. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  404. # asset_path: buildkit-linux.zip
  405. # asset_name: buildkit-linux.zip
  406. # asset_content_type: application/zip
  407. # - name: Upload buildkit-mac.zip to GitHub Releases
  408. # uses: actions/upload-release-asset@v1.0.1
  409. # env:
  410. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  411. # with:
  412. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  413. # asset_path: buildkit-mac.zip
  414. # asset_name: buildkit-mac.zip
  415. # asset_content_type: application/zip
  416. # - name: Upload buildkit-win.zip to GitHub Releases
  417. # uses: actions/upload-release-asset@v1.0.1
  418. # env:
  419. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  420. # with:
  421. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  422. # asset_path: buildkit-win.zip
  423. # asset_name: buildkit-win.zip
  424. # asset_content_type: application/zip
  425. # - name: Upload tarball signature to GitHub Releases
  426. # uses: actions/upload-release-asset@v1.0.1
  427. # env:
  428. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  429. # with:
  430. # upload_url: ${{ steps.create_release.outputs.upload_url }}
  431. # asset_path: "cryptomator-${{ github.ref }}.tar.gz.asc"
  432. # asset_name: "cryptomator-${{ github.ref }}.tar.gz.asc"
  433. # asset_content_type: application/octet-stream