build.yml 4.0 KB

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