|
| 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 | + paths: |
| 23 | + - "intellij/**" |
| 24 | + |
| 25 | +jobs: |
| 26 | + |
| 27 | + # Prepare environment and build the plugin |
| 28 | + build: |
| 29 | + name: Build |
| 30 | + runs-on: ubuntu-latest |
| 31 | + outputs: |
| 32 | + version: ${{ steps.properties.outputs.version }} |
| 33 | + changelog: ${{ steps.properties.outputs.changelog }} |
| 34 | + pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }} |
| 35 | + steps: |
| 36 | + |
| 37 | + # Check out current repository |
| 38 | + - name: Fetch Sources |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + # Validate wrapper |
| 42 | + - name: Gradle Wrapper Validation |
| 43 | + |
| 44 | + |
| 45 | + # Set up Java environment for the next steps |
| 46 | + - name: Setup Java |
| 47 | + uses: actions/setup-java@v4 |
| 48 | + with: |
| 49 | + distribution: zulu |
| 50 | + java-version: 17 |
| 51 | + |
| 52 | + # Setup Gradle |
| 53 | + - name: Setup Gradle |
| 54 | + uses: gradle/gradle-build-action@v2 |
| 55 | + with: |
| 56 | + gradle-home-cache-cleanup: true |
| 57 | + |
| 58 | + # Set environment variables |
| 59 | + - name: Export Properties |
| 60 | + working-directory: ./intellij |
| 61 | + id: properties |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + PROPERTIES="$(./gradlew properties --console=plain -q)" |
| 65 | + VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" |
| 66 | + CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" |
| 67 | +
|
| 68 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 69 | + echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT |
| 70 | + |
| 71 | + echo "changelog<<EOF" >> $GITHUB_OUTPUT |
| 72 | + echo "$CHANGELOG" >> $GITHUB_OUTPUT |
| 73 | + echo "EOF" >> $GITHUB_OUTPUT |
| 74 | +
|
| 75 | + ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier |
| 76 | +
|
| 77 | + # Build plugin |
| 78 | + - name: Build plugin |
| 79 | + working-directory: ./intellij |
| 80 | + run: ./gradlew buildPlugin |
| 81 | + |
| 82 | + # Prepare plugin archive content for creating artifact |
| 83 | + - name: Prepare Plugin Artifact |
| 84 | + id: artifact |
| 85 | + shell: bash |
| 86 | + run: | |
| 87 | + cd ${{ github.workspace }}/intellij/build/distributions |
| 88 | + FILENAME=`ls *.zip` |
| 89 | + unzip "$FILENAME" -d content |
| 90 | +
|
| 91 | + echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT |
| 92 | +
|
| 93 | + # Store already-built plugin as an artifact for downloading |
| 94 | + - name: Upload artifact |
| 95 | + uses: actions/upload-artifact@v3 |
| 96 | + with: |
| 97 | + name: ${{ steps.artifact.outputs.filename }} |
| 98 | + path: ./intellij/build/distributions/content/*/* |
| 99 | + |
| 100 | + # Run tests and upload a code coverage report |
| 101 | + test: |
| 102 | + name: Test |
| 103 | + needs: [ build ] |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + |
| 107 | + # Check out current repository |
| 108 | + - name: Fetch Sources |
| 109 | + uses: actions/checkout@v4 |
| 110 | + |
| 111 | + # Set up Java environment for the next steps |
| 112 | + - name: Setup Java |
| 113 | + uses: actions/setup-java@v4 |
| 114 | + with: |
| 115 | + distribution: zulu |
| 116 | + java-version: 17 |
| 117 | + |
| 118 | + # Setup Gradle |
| 119 | + - name: Setup Gradle |
| 120 | + uses: gradle/gradle-build-action@v2 |
| 121 | + with: |
| 122 | + gradle-home-cache-cleanup: true |
| 123 | + |
| 124 | + # Run tests |
| 125 | + - name: Run Tests |
| 126 | + working-directory: ./intellij |
| 127 | + run: ./gradlew check |
| 128 | + |
| 129 | + # Collect Tests Result of failed tests |
| 130 | + - name: Collect Tests Result |
| 131 | + if: ${{ failure() }} |
| 132 | + uses: actions/upload-artifact@v3 |
| 133 | + with: |
| 134 | + name: tests-result |
| 135 | + path: ${{ github.workspace }}/intellij/build/reports/tests |
| 136 | + |
| 137 | + # Upload the Kover report to CodeCov |
| 138 | + - name: Upload Code Coverage Report |
| 139 | + uses: codecov/codecov-action@v3 |
| 140 | + with: |
| 141 | + files: ${{ github.workspace }}/intellij/build/reports/kover/report.xml |
| 142 | + |
| 143 | + # Run Qodana inspections and provide report |
| 144 | + inspectCode: |
| 145 | + name: Inspect code |
| 146 | + needs: [ build ] |
| 147 | + runs-on: ubuntu-latest |
| 148 | + permissions: |
| 149 | + contents: write |
| 150 | + checks: write |
| 151 | + pull-requests: write |
| 152 | + steps: |
| 153 | + |
| 154 | + # Free GitHub Actions Environment Disk Space |
| 155 | + - name: Maximize Build Space |
| 156 | + uses: jlumbroso/free-disk-space@main |
| 157 | + with: |
| 158 | + tool-cache: false |
| 159 | + large-packages: false |
| 160 | + |
| 161 | + # Check out current repository |
| 162 | + - name: Fetch Sources |
| 163 | + uses: actions/checkout@v4 |
| 164 | + |
| 165 | + # Set up Java environment for the next steps |
| 166 | + - name: Setup Java |
| 167 | + uses: actions/setup-java@v4 |
| 168 | + with: |
| 169 | + distribution: zulu |
| 170 | + java-version: 17 |
| 171 | + |
| 172 | + |
| 173 | + # Run plugin structure verification along with IntelliJ Plugin Verifier |
| 174 | + verify: |
| 175 | + name: Verify plugin |
| 176 | + needs: [ build ] |
| 177 | + runs-on: ubuntu-latest |
| 178 | + steps: |
| 179 | + |
| 180 | + # Free GitHub Actions Environment Disk Space |
| 181 | + - name: Maximize Build Space |
| 182 | + uses: jlumbroso/free-disk-space@main |
| 183 | + with: |
| 184 | + tool-cache: false |
| 185 | + large-packages: false |
| 186 | + |
| 187 | + # Check out current repository |
| 188 | + - name: Fetch Sources |
| 189 | + uses: actions/checkout@v4 |
| 190 | + |
| 191 | + # Set up Java environment for the next steps |
| 192 | + - name: Setup Java |
| 193 | + uses: actions/setup-java@v4 |
| 194 | + with: |
| 195 | + distribution: zulu |
| 196 | + java-version: 17 |
| 197 | + |
| 198 | + # Setup Gradle |
| 199 | + - name: Setup Gradle |
| 200 | + uses: gradle/gradle-build-action@v2 |
| 201 | + with: |
| 202 | + gradle-home-cache-cleanup: true |
| 203 | + |
| 204 | + # Cache Plugin Verifier IDEs |
| 205 | + - name: Setup Plugin Verifier IDEs Cache |
| 206 | + uses: actions/cache@v3 |
| 207 | + with: |
| 208 | + path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides |
| 209 | + key: plugin-verifier-${{ hashFiles('intellij/build/listProductsReleases.txt') }} |
| 210 | + |
| 211 | + # Run Verify Plugin task and IntelliJ Plugin Verifier tool |
| 212 | + - name: Run Plugin Verification tasks |
| 213 | + working-directory: ./intellij |
| 214 | + run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} |
| 215 | + |
| 216 | + # Collect Plugin Verifier Result |
| 217 | + - name: Collect Plugin Verifier Result |
| 218 | + if: ${{ always() }} |
| 219 | + uses: actions/upload-artifact@v3 |
| 220 | + with: |
| 221 | + name: pluginVerifier-result |
| 222 | + path: ${{ github.workspace }}/intellij/build/reports/pluginVerifier |
| 223 | + |
| 224 | + # Prepare a draft release for GitHub Releases page for the manual verification |
| 225 | + # If accepted and published, release workflow would be triggered |
| 226 | +# releaseDraft: |
| 227 | +# name: Release draft |
| 228 | +# if: github.event_name != 'pull_request' |
| 229 | +# needs: [ build, test, inspectCode, verify ] |
| 230 | +# runs-on: ubuntu-latest |
| 231 | +# permissions: |
| 232 | +# contents: write |
| 233 | +# steps: |
| 234 | +# |
| 235 | +# # Check out current repository |
| 236 | +# - name: Fetch Sources |
| 237 | +# uses: actions/checkout@v4 |
| 238 | +# |
| 239 | +# # Set up Java environment for the next steps |
| 240 | +# - name: Setup Java |
| 241 | +# uses: actions/setup-java@v4 |
| 242 | +# with: |
| 243 | +# distribution: zulu |
| 244 | +# java-version: 17 |
| 245 | +# |
| 246 | +# # Remove old release drafts by using the curl request for the available releases with a draft flag |
| 247 | +# - name: Remove Old Release Drafts |
| 248 | +# env: |
| 249 | +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 250 | +# run: | |
| 251 | +# gh api repos/{owner}/{repo}/releases \ |
| 252 | +# --jq '.[] | select(.draft == true) | .id' \ |
| 253 | +# | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} |
| 254 | +# |
| 255 | +# # Create a new release draft which is not publicly visible and requires manual acceptance |
| 256 | +# - name: Create Release Draft |
| 257 | +# env: |
| 258 | +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 259 | +# run: | |
| 260 | +# gh release create v${{ needs.build.outputs.version }} \ |
| 261 | +# --draft \ |
| 262 | +# --title "v${{ needs.build.outputs.version }}" \ |
| 263 | +# --notes "$(cat << 'EOM' |
| 264 | +# ${{ needs.build.outputs.changelog }} |
| 265 | +# EOM |
| 266 | +# )" |
0 commit comments