build.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. # GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
  2. # - validate Gradle Wrapper,
  3. # - run test and verifyPlugin tasks,
  4. # - run buildPlugin task and prepare artifact for the further tests,
  5. # - run IntelliJ Plugin Verifier,
  6. # - create a draft release.
  7. #
  8. # Workflow is triggered on push and pull_request events.
  9. #
  10. # Docs:
  11. # - GitHub Actions: https://help.github.com/en/actions
  12. # - IntelliJ Plugin Verifier GitHub Action: https://github.com/ChrisCarini/intellij-platform-plugin-verifier-action
  13. #
  14. name: Build
  15. on:
  16. pull_request:
  17. branches:
  18. - master
  19. jobs:
  20. # Run Gradle Wrapper Validation Action to verify the wrapper's checksum
  21. gradleValidation:
  22. name: Gradle Wrapper
  23. runs-on: ubuntu-latest
  24. steps:
  25. - name: Fetch Sources
  26. uses: actions/checkout@v4
  27. - name: Gradle Wrapper Validation
  28. uses: gradle/wrapper-validation-action@v1.1.0
  29. # Run verifyPlugin and test Gradle tasks
  30. test:
  31. name: Test
  32. needs: gradleValidation
  33. runs-on: ubuntu-latest
  34. steps:
  35. - name: Setup Java
  36. uses: actions/setup-java@v3
  37. with:
  38. java-version: 11
  39. distribution: 'zulu'
  40. - name: Fetch Sources
  41. uses: actions/checkout@v4
  42. - name: Setup Gradle Dependencies Cache
  43. uses: actions/cache@v4.0.2
  44. with:
  45. path: ~/.gradle/caches
  46. key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
  47. - name: Setup Gradle Wrapper Cache
  48. uses: actions/cache@v4.0.2
  49. with:
  50. path: ~/.gradle/wrapper
  51. key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
  52. - name: Run Linters and Test
  53. run: ./gradlew check
  54. - name: Verify Plugin
  55. run: ./gradlew verifyPlugin
  56. # Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
  57. # Requires test job to be passed
  58. build:
  59. name: Build
  60. needs: test
  61. runs-on: ubuntu-latest
  62. outputs:
  63. name: ${{ steps.properties.outputs.name }}
  64. version: ${{ steps.properties.outputs.version }}
  65. artifact: ${{ steps.properties.outputs.artifact }}
  66. steps:
  67. - name: Setup Java
  68. uses: actions/setup-java@v3
  69. with:
  70. java-version: 11
  71. distribution: 'zulu'
  72. - name: Fetch Sources
  73. uses: actions/checkout@v4
  74. - name: Setup Gradle Dependencies Cache
  75. uses: actions/cache@v4.0.2
  76. with:
  77. path: ~/.gradle/caches
  78. key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
  79. - name: Setup Gradle Wrapper Cache
  80. uses: actions/cache@v4.0.2
  81. with:
  82. path: ~/.gradle/wrapper
  83. key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
  84. - name: Set environment variables
  85. id: properties
  86. shell: bash
  87. run: |
  88. PROPERTIES="$(./gradlew properties --console=plain -q)"
  89. VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
  90. NAME="$(echo "$PROPERTIES" | grep "^pluginName_:" | cut -f2- -d ' ')"
  91. ARTIFACT="${NAME}-${VERSION}.zip"
  92. echo "::set-output name=version::$VERSION"
  93. echo "::set-output name=name::$NAME"
  94. echo "::set-output name=artifact::$ARTIFACT"
  95. - name: Build Plugin
  96. run: ./gradlew buildPlugin
  97. # Upload plugin artifact to make it available in the next jobs
  98. - name: Upload artifact
  99. uses: actions/upload-artifact@v4.2.0
  100. with:
  101. name: plugin-artifact
  102. path: ./build/distributions/${{ needs.build.outputs.artifact }}
  103. # Verify built plugin using IntelliJ Plugin Verifier tool
  104. # Requires build job to be passed
  105. verify:
  106. name: Verify
  107. needs: build
  108. runs-on: ubuntu-latest
  109. steps:
  110. - name: Setup Java
  111. uses: actions/setup-java@v3
  112. with:
  113. java-version: 11
  114. distribution: 'zulu'
  115. - name: Fetch Sources
  116. uses: actions/checkout@v4
  117. - name: Setup Gradle Dependencies Cache
  118. uses: actions/cache@v4.0.2
  119. with:
  120. path: ~/.gradle/caches
  121. key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
  122. - name: Setup Gradle Wrapper Cache
  123. uses: actions/cache@v4.0.2
  124. with:
  125. path: ~/.gradle/wrapper
  126. key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
  127. # Set environment variables
  128. - name: Export Properties
  129. id: properties
  130. shell: bash
  131. run: |
  132. PROPERTIES="$(./gradlew properties --console=plain -q)"
  133. IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
  134. echo "::set-output name=ideVersions::$IDE_VERSIONS"
  135. echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
  136. # Cache Plugin Verifier IDEs
  137. - name: Setup Plugin Verifier IDEs Cache
  138. uses: actions/cache@v4.0.2
  139. with:
  140. path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
  141. key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
  142. # Run IntelliJ Plugin Verifier action using GitHub Action
  143. - name: Verify Plugin
  144. run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}