build.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. name: Build
  2. on:
  3. push:
  4. pull_request_target:
  5. types: [labeled]
  6. env:
  7. JAVA_VERSION: 17
  8. defaults:
  9. run:
  10. shell: bash
  11. jobs:
  12. release-check-precondition:
  13. name: Validate pushed commit to release/hotfix branch or pushed tag
  14. runs-on: ubuntu-latest
  15. if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/hotfix/') || startsWith(github.ref, 'refs/heads/release/')
  16. steps:
  17. - uses: actions/checkout@v2
  18. - id: validate-pom-version
  19. name: Validate POM version
  20. run: |
  21. if [[ $GITHUB_REF =~ refs/heads/(hotfix|release)/[0-9]+\.[0-9]+\.[0-9]+.* ]]; then
  22. SEM_VER_STR=${GITHUB_REF##*/}
  23. elif [[ $GITHUB_REF =~ refs/tags/[0-9]+\.[0-9]+\.[0-9]+.* ]]; then
  24. SEM_VER_STR=${GITHUB_REF##*/}
  25. else
  26. echo "Failed to parse version"
  27. exit 1
  28. fi
  29. if [[ ${SEM_VER_STR} == `mvn help:evaluate -Dexpression=project.version -q -DforceStdout` ]]; then
  30. echo "::set-output name=semVerStr::${SEM_VER_STR}"
  31. else
  32. echo "Version not set in POM"
  33. exit 1
  34. fi
  35. - name: Validate release in org.cryptomator.Cryptomator.metainfo.xml file
  36. run: |
  37. if ! grep -q "<release date=\".*\" version=\"${{ steps.validate-pom-version.outputs.semVerStr }}\"/>" dist/linux/common/org.cryptomator.Cryptomator.metainfo.xml; then
  38. echo "Release not set in dist/linux/common/org.cryptomator.Cryptomator.metainfo.xml"
  39. exit 1
  40. fi
  41. test:
  42. name: Compile and Test
  43. needs: release-check-precondition
  44. runs-on: ubuntu-latest
  45. if: "always() && (needs.release-check-precondition.result=='success' || needs.release-check-precondition.result=='skipped') && !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
  46. steps:
  47. - uses: actions/checkout@v2
  48. - uses: actions/setup-java@v2
  49. with:
  50. distribution: 'temurin'
  51. java-version: ${{ env.JAVA_VERSION }}
  52. cache: 'maven'
  53. - name: Cache SonarCloud packages
  54. uses: actions/cache@v2
  55. with:
  56. path: ~/.sonar/cache
  57. key: ${{ runner.os }}-sonar
  58. restore-keys: ${{ runner.os }}-sonar
  59. - name: Build and Test
  60. run: >
  61. xvfb-run
  62. mvn -B verify
  63. jacoco:report
  64. org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
  65. -Pcoverage,dependency-check
  66. -Dsonar.projectKey=cryptomator_cryptomator
  67. -Dsonar.organization=cryptomator
  68. -Dsonar.host.url=https://sonarcloud.io
  69. env:
  70. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
  71. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  72. - name: Sign source tarball with key 615D449FE6E6A235
  73. if: startsWith(github.ref, 'refs/tags/')
  74. run: |
  75. git archive --prefix="cryptomator-${{ github.ref_name }}/" -o "cryptomator-${{ github.ref_name }}.tar.gz" ${{ github.ref }}
  76. echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import
  77. echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a cryptomator-*.tar.gz
  78. env:
  79. GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
  80. GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
  81. - name: Draft a release
  82. if: startsWith(github.ref, 'refs/tags/')
  83. uses: softprops/action-gh-release@v1
  84. with:
  85. draft: true
  86. discussion_category_name: releases
  87. token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
  88. generate_release_notes: true
  89. files: |
  90. cryptomator-*.tar.gz.asc
  91. fail_on_unmatched_files: true
  92. body: |-
  93. :construction: Work in Progress
  94. ---