|
| 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 Qodana inspections, |
| 5 | +# - run 'buildPlugin' task and prepare artifact for the further tests, |
| 6 | +# - run 'runPluginVerifier' task, |
| 7 | +# - create a draft release. |
| 8 | +# |
| 9 | +# 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 | +jobs: |
| 24 | + |
| 25 | + # Run Gradle Wrapper Validation Action to verify the wrapper's checksum |
| 26 | + # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks |
| 27 | + # Build plugin and provide the artifact for the next workflow jobs |
| 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 | + steps: |
| 35 | + |
| 36 | + # Check out current repository |
| 37 | + - name: Fetch Sources |
| 38 | + |
| 39 | + |
| 40 | + # Validate wrapper |
| 41 | + - name: Gradle Wrapper Validation |
| 42 | + |
| 43 | + |
| 44 | + # Setup Java 11 environment for the next steps |
| 45 | + - name: Setup Java |
| 46 | + uses: actions/setup-java@v2 |
| 47 | + with: |
| 48 | + distribution: zulu |
| 49 | + java-version: 11 |
| 50 | + cache: gradle |
| 51 | + |
| 52 | + # Set environment variables |
| 53 | + - name: Export Properties |
| 54 | + id: properties |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + PROPERTIES="$(./gradlew properties --console=plain -q)" |
| 58 | + VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" |
| 59 | + NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')" |
| 60 | + CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" |
| 61 | + CHANGELOG="${CHANGELOG//'%'/'%25'}" |
| 62 | + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" |
| 63 | + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" |
| 64 | +
|
| 65 | + echo "::set-output name=version::$VERSION" |
| 66 | + echo "::set-output name=name::$NAME" |
| 67 | + echo "::set-output name=changelog::$CHANGELOG" |
| 68 | + echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier" |
| 69 | +
|
| 70 | + ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier |
| 71 | +
|
| 72 | + # Run tests |
| 73 | + - name: Run Tests |
| 74 | + run: ./gradlew test |
| 75 | + |
| 76 | + # Collect Tests Result of failed tests |
| 77 | + - name: Collect Tests Result |
| 78 | + if: ${{ failure() }} |
| 79 | + uses: actions/upload-artifact@v2 |
| 80 | + with: |
| 81 | + name: tests-result |
| 82 | + path: ${{ github.workspace }}/build/reports/tests |
| 83 | + |
| 84 | + # Cache Plugin Verifier IDEs |
| 85 | + - name: Setup Plugin Verifier IDEs Cache |
| 86 | + |
| 87 | + with: |
| 88 | + path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides |
| 89 | + key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} |
| 90 | + |
| 91 | + # Run Verify Plugin task and IntelliJ Plugin Verifier tool |
| 92 | + - name: Run Plugin Verification tasks |
| 93 | + run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }} |
| 94 | + |
| 95 | + # Collect Plugin Verifier Result |
| 96 | + - name: Collect Plugin Verifier Result |
| 97 | + if: ${{ always() }} |
| 98 | + uses: actions/upload-artifact@v2 |
| 99 | + with: |
| 100 | + name: pluginVerifier-result |
| 101 | + path: ${{ github.workspace }}/build/reports/pluginVerifier |
| 102 | + |
| 103 | + # Run Qodana inspections |
| 104 | + - name: Qodana - Code Inspection |
| 105 | + |
| 106 | + |
| 107 | + # Collect Qodana Result |
| 108 | + - name: Collect Qodana Result |
| 109 | + uses: actions/upload-artifact@v2 |
| 110 | + with: |
| 111 | + name: qodana-result |
| 112 | + path: ${{ github.workspace }}/qodana |
| 113 | + |
| 114 | + # Prepare plugin archive content for creating artifact |
| 115 | + - name: Prepare Plugin Artifact |
| 116 | + id: artifact |
| 117 | + shell: bash |
| 118 | + run: | |
| 119 | + cd ${{ github.workspace }}/build/distributions |
| 120 | + FILENAME=`ls *.zip` |
| 121 | + unzip "$FILENAME" -d content |
| 122 | +
|
| 123 | + echo "::set-output name=filename::$FILENAME" |
| 124 | +
|
| 125 | + # Store already-built plugin as an artifact for downloading |
| 126 | + - name: Upload artifact |
| 127 | + |
| 128 | + with: |
| 129 | + name: ${{ steps.artifact.outputs.filename }} |
| 130 | + path: ./build/distributions/content/*/* |
| 131 | + |
| 132 | + # Prepare a draft release for GitHub Releases page for the manual verification |
| 133 | + # If accepted and published, release workflow would be triggered |
| 134 | + releaseDraft: |
| 135 | + name: Release Draft |
| 136 | + if: github.event_name != 'pull_request' |
| 137 | + needs: build |
| 138 | + runs-on: ubuntu-latest |
| 139 | + steps: |
| 140 | + |
| 141 | + # Check out current repository |
| 142 | + - name: Fetch Sources |
| 143 | + |
| 144 | + |
| 145 | + # Remove old release drafts by using the curl request for the available releases with draft flag |
| 146 | + - name: Remove Old Release Drafts |
| 147 | + env: |
| 148 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 149 | + run: | |
| 150 | + gh api repos/{owner}/{repo}/releases \ |
| 151 | + --jq '.[] | select(.draft == true) | .id' \ |
| 152 | + | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} |
| 153 | +
|
| 154 | + # Create new release draft - which is not publicly visible and requires manual acceptance |
| 155 | + - name: Create Release Draft |
| 156 | + env: |
| 157 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 158 | + run: | |
| 159 | + gh release create v${{ needs.build.outputs.version }} \ |
| 160 | + --draft \ |
| 161 | + --title "v${{ needs.build.outputs.version }}" \ |
| 162 | + --notes "$(cat << 'EOM' |
| 163 | + ${{ needs.build.outputs.changelog }} |
| 164 | + EOM |
| 165 | + )" |
0 commit comments