|
| 1 | +# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps: |
| 2 | +# - Validate Gradle Wrapper. |
| 3 | +# - Run 'test' and 'verifyPlugin' tasks. |
| 4 | +# - Run Qodana inspections. |
| 5 | +# - Run the 'buildPlugin' task and prepare artifact for further tests. |
| 6 | +# - Run the 'runPluginVerifier' task. |
| 7 | +# - Create a draft release. |
| 8 | +# |
| 9 | +# The workflow is triggered on push and pull_request events. |
| 10 | +# |
| 11 | +# GitHub Actions reference: https://help.github.com/en/actions |
| 12 | +# |
| 13 | +## JBIJPPTPL |
| 14 | + |
| 15 | +name: Build |
| 16 | +on: |
| 17 | + # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests) |
| 18 | + push: |
| 19 | + branches: [ main ] |
| 20 | + # Trigger the workflow on any pull request |
| 21 | + pull_request: |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + |
| 29 | + # Prepare the environment and build the plugin |
| 30 | + build: |
| 31 | + name: Build |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + |
| 35 | + # Free GitHub Actions Environment Disk Space |
| 36 | + - name: Maximize Build Space |
| 37 | + |
| 38 | + with: |
| 39 | + tool-cache: false |
| 40 | + large-packages: false |
| 41 | + |
| 42 | + # Check out the current repository |
| 43 | + - name: Fetch Sources |
| 44 | + uses: actions/checkout@v4 |
| 45 | + |
| 46 | + # Set up the Java environment for the next steps |
| 47 | + - name: Setup Java |
| 48 | + uses: actions/setup-java@v4 |
| 49 | + with: |
| 50 | + distribution: zulu |
| 51 | + java-version: 21 |
| 52 | + |
| 53 | + # Setup Gradle |
| 54 | + - name: Setup Gradle |
| 55 | + uses: gradle/actions/setup-gradle@v4 |
| 56 | + |
| 57 | + # Build plugin |
| 58 | + - name: Build plugin |
| 59 | + run: ./gradlew buildPlugin |
| 60 | + |
| 61 | + # Prepare plugin archive content for creating artifact |
| 62 | + - name: Prepare Plugin Artifact |
| 63 | + id: artifact |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + cd ${{ github.workspace }}/build/distributions |
| 67 | + FILENAME=`ls *.zip` |
| 68 | + unzip "$FILENAME" -d content |
| 69 | +
|
| 70 | + echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT |
| 71 | +
|
| 72 | + # Store an already-built plugin as an artifact for downloading |
| 73 | + - name: Upload artifact |
| 74 | + uses: actions/upload-artifact@v4 |
| 75 | + with: |
| 76 | + name: ${{ steps.artifact.outputs.filename }} |
| 77 | + path: ./build/distributions/content/*/* |
| 78 | + |
| 79 | + # Run tests and upload a code coverage report |
| 80 | + test: |
| 81 | + name: Test |
| 82 | + needs: [ build ] |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + |
| 86 | + # Free GitHub Actions Environment Disk Space |
| 87 | + - name: Maximize Build Space |
| 88 | + |
| 89 | + with: |
| 90 | + tool-cache: false |
| 91 | + large-packages: false |
| 92 | + |
| 93 | + # Check out the current repository |
| 94 | + - name: Fetch Sources |
| 95 | + uses: actions/checkout@v4 |
| 96 | + |
| 97 | + # Set up the Java environment for the next steps |
| 98 | + - name: Setup Java |
| 99 | + uses: actions/setup-java@v4 |
| 100 | + with: |
| 101 | + distribution: zulu |
| 102 | + java-version: 21 |
| 103 | + |
| 104 | + # Setup Gradle |
| 105 | + - name: Setup Gradle |
| 106 | + uses: gradle/actions/setup-gradle@v4 |
| 107 | + with: |
| 108 | + cache-read-only: true |
| 109 | + |
| 110 | + # Run tests |
| 111 | + - name: Run Tests |
| 112 | + run: ./gradlew check |
| 113 | + |
| 114 | + # Collect Tests Result of failed tests |
| 115 | + - name: Collect Tests Result |
| 116 | + if: ${{ failure() }} |
| 117 | + uses: actions/upload-artifact@v4 |
| 118 | + with: |
| 119 | + name: tests-result |
| 120 | + path: ${{ github.workspace }}/build/reports/tests |
| 121 | + |
| 122 | + # Upload the Kover report to CodeCov |
| 123 | + - name: Upload Code Coverage Report |
| 124 | + uses: codecov/codecov-action@v5 |
| 125 | + with: |
| 126 | + files: ${{ github.workspace }}/build/reports/kover/report.xml |
| 127 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 128 | + |
| 129 | + # Run Qodana inspections and provide a report |
| 130 | + inspectCode: |
| 131 | + name: Inspect code |
| 132 | + needs: [ build ] |
| 133 | + runs-on: ubuntu-latest |
| 134 | + permissions: |
| 135 | + contents: write |
| 136 | + checks: write |
| 137 | + pull-requests: write |
| 138 | + steps: |
| 139 | + |
| 140 | + # Free GitHub Actions Environment Disk Space |
| 141 | + - name: Maximize Build Space |
| 142 | + |
| 143 | + with: |
| 144 | + tool-cache: false |
| 145 | + large-packages: false |
| 146 | + |
| 147 | + # Check out the current repository |
| 148 | + - name: Fetch Sources |
| 149 | + uses: actions/checkout@v4 |
| 150 | + with: |
| 151 | + ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit |
| 152 | + fetch-depth: 0 # a full history is required for pull request analysis |
| 153 | + |
| 154 | + # Set up the Java environment for the next steps |
| 155 | + - name: Setup Java |
| 156 | + uses: actions/setup-java@v4 |
| 157 | + with: |
| 158 | + distribution: zulu |
| 159 | + java-version: 21 |
| 160 | + |
| 161 | + # Run Qodana inspections |
| 162 | + - name: Qodana - Code Inspection |
| 163 | + |
| 164 | + with: |
| 165 | + cache-default-branch-only: true |
| 166 | + |
| 167 | + # Run plugin structure verification along with IntelliJ Plugin Verifier |
| 168 | + verify: |
| 169 | + name: Verify plugin |
| 170 | + needs: [ build ] |
| 171 | + runs-on: ubuntu-latest |
| 172 | + steps: |
| 173 | + |
| 174 | + # Free GitHub Actions Environment Disk Space |
| 175 | + - name: Maximize Build Space |
| 176 | + |
| 177 | + with: |
| 178 | + tool-cache: false |
| 179 | + large-packages: false |
| 180 | + |
| 181 | + # Check out the current repository |
| 182 | + - name: Fetch Sources |
| 183 | + uses: actions/checkout@v4 |
| 184 | + |
| 185 | + # Set up the Java environment for the next steps |
| 186 | + - name: Setup Java |
| 187 | + uses: actions/setup-java@v4 |
| 188 | + with: |
| 189 | + distribution: zulu |
| 190 | + java-version: 21 |
| 191 | + |
| 192 | + # Setup Gradle |
| 193 | + - name: Setup Gradle |
| 194 | + uses: gradle/actions/setup-gradle@v4 |
| 195 | + with: |
| 196 | + cache-read-only: true |
| 197 | + |
| 198 | + # Run Verify Plugin task and IntelliJ Plugin Verifier tool |
| 199 | + - name: Run Plugin Verification tasks |
| 200 | + run: ./gradlew verifyPlugin |
| 201 | + |
| 202 | + # Collect Plugin Verifier Result |
| 203 | + - name: Collect Plugin Verifier Result |
| 204 | + if: ${{ always() }} |
| 205 | + uses: actions/upload-artifact@v4 |
| 206 | + with: |
| 207 | + name: pluginVerifier-result |
| 208 | + path: ${{ github.workspace }}/build/reports/pluginVerifier |
| 209 | + |
| 210 | + # Prepare a draft release for GitHub Releases page for the manual verification |
| 211 | + # If accepted and published, the release workflow would be triggered |
| 212 | + releaseDraft: |
| 213 | + name: Release draft |
| 214 | + if: github.event_name != 'pull_request' |
| 215 | + needs: [ build, test, inspectCode, verify ] |
| 216 | + runs-on: ubuntu-latest |
| 217 | + permissions: |
| 218 | + contents: write |
| 219 | + steps: |
| 220 | + |
| 221 | + # Check out the current repository |
| 222 | + - name: Fetch Sources |
| 223 | + uses: actions/checkout@v4 |
| 224 | + |
| 225 | + # Remove old release drafts by using the curl request for the available releases with a draft flag |
| 226 | + - name: Remove Old Release Drafts |
| 227 | + env: |
| 228 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 229 | + run: | |
| 230 | + gh api repos/{owner}/{repo}/releases \ |
| 231 | + --jq '.[] | select(.draft == true) | .id' \ |
| 232 | + | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} |
| 233 | +
|
| 234 | + # Create a new release draft which is not publicly visible and requires manual acceptance |
| 235 | + - name: Create Release Draft |
| 236 | + env: |
| 237 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 238 | + run: | |
| 239 | + VERSION=$(./gradlew properties --property version --quiet --console=plain | tail -n 1 | cut -f2- -d ' ') |
| 240 | + RELEASE_NOTE="./build/tmp/release_note.txt" |
| 241 | + ./gradlew getChangelog --unreleased --no-header --quiet --console=plain --output-file=$RELEASE_NOTE |
| 242 | + |
| 243 | + gh release create $VERSION \ |
| 244 | + --draft \ |
| 245 | + --title $VERSION \ |
| 246 | + --notes-file $RELEASE_NOTE |
0 commit comments