|
| 1 | +# GitHub Actions Workflow created for handling the release process based on the draft release prepared with the Build workflow. |
| 2 | +# Running the publishPlugin task requires all following secrets to be provided: PUBLISH_TOKEN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, CERTIFICATE_CHAIN. |
| 3 | +# See https://plugins.jetbrains.com/docs/intellij/plugin-signing.html for more information. |
| 4 | + |
| 5 | +name: Release |
| 6 | +on: |
| 7 | + release: |
| 8 | + types: [prereleased, released] |
| 9 | + |
| 10 | +jobs: |
| 11 | + |
| 12 | + # Prepare and publish the plugin to JetBrains Marketplace repository |
| 13 | + release: |
| 14 | + name: Publish Plugin |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + contents: write |
| 18 | + pull-requests: write |
| 19 | + steps: |
| 20 | + |
| 21 | + # Check out current repository |
| 22 | + - name: Fetch Sources |
| 23 | + uses: actions/checkout@v3 |
| 24 | + with: |
| 25 | + ref: ${{ github.event.release.tag_name }} |
| 26 | + |
| 27 | + # Setup Java environment for the next steps |
| 28 | + - name: Setup Java |
| 29 | + uses: actions/setup-java@v3 |
| 30 | + with: |
| 31 | + distribution: zulu |
| 32 | + java-version: 17 |
| 33 | + |
| 34 | + # Setup Gradle |
| 35 | + - name: Setup Gradle |
| 36 | + uses: gradle/gradle-build-action@v2 |
| 37 | + |
| 38 | + # Set environment variables |
| 39 | + - name: Export Properties |
| 40 | + id: properties |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d' |
| 44 | + ${{ github.event.release.body }} |
| 45 | + EOM |
| 46 | + )" |
| 47 | + |
| 48 | + echo "changelog<<EOF" >> $GITHUB_OUTPUT |
| 49 | + echo "$CHANGELOG" >> $GITHUB_OUTPUT |
| 50 | + echo "EOF" >> $GITHUB_OUTPUT |
| 51 | +
|
| 52 | + # Update Unreleased section with the current release note |
| 53 | + - name: Patch Changelog |
| 54 | + if: ${{ steps.properties.outputs.changelog != '' }} |
| 55 | + env: |
| 56 | + CHANGELOG: ${{ steps.properties.outputs.changelog }} |
| 57 | + run: | |
| 58 | + ./gradlew patchChangelog --release-note="$CHANGELOG" |
| 59 | +
|
| 60 | + # Publish the plugin to JetBrains Marketplace |
| 61 | + - name: Publish Plugin |
| 62 | + env: |
| 63 | + PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} |
| 64 | + run: ./gradlew :plugin:publishPlugin |
| 65 | + |
| 66 | + # Upload artifact as a release asset |
| 67 | + - name: Upload Release Asset |
| 68 | + env: |
| 69 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + run: gh release upload ${{ github.event.release.tag_name }} ./plugin/build/distributions/* |
| 71 | + |
| 72 | + # Create pull request |
| 73 | + - name: Create Pull Request |
| 74 | + if: ${{ steps.properties.outputs.changelog != '' }} |
| 75 | + env: |
| 76 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + run: | |
| 78 | + VERSION="${{ github.event.release.tag_name }}" |
| 79 | + BRANCH="changelog-update-$VERSION" |
| 80 | + LABEL="release changelog" |
| 81 | +
|
| 82 | + git config user.email "action@github.com" |
| 83 | + git config user.name "GitHub Action" |
| 84 | +
|
| 85 | + git checkout -b $BRANCH |
| 86 | + git commit -am "Changelog update - $VERSION" |
| 87 | + git push --set-upstream origin $BRANCH |
| 88 | + |
| 89 | + gh label create "$LABEL" \ |
| 90 | + --description "Pull requests with release changelog update" \ |
| 91 | + || true |
| 92 | +
|
| 93 | + gh pr create \ |
| 94 | + --title "Changelog update - \`$VERSION\`" \ |
| 95 | + --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \ |
| 96 | + --label "$LABEL" \ |
| 97 | + --head $BRANCH |
0 commit comments