build.yml 3.5 KB

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