|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + pull-requests: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + check_code: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 30 |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Set up JDK |
| 19 | + uses: actions/setup-java@v4 |
| 20 | + with: |
| 21 | + java-version: '21' |
| 22 | + distribution: 'temurin' |
| 23 | + cache: 'gradle' |
| 24 | + |
| 25 | + - name: Build |
| 26 | + run: ./gradlew build buildPlugin --info --stacktrace |
| 27 | + |
| 28 | + - name: Check for uncommited changes |
| 29 | + run: | |
| 30 | + if [[ "$(git status --porcelain)" != "" ]]; then |
| 31 | + echo ---------------------------------------- |
| 32 | + echo git status |
| 33 | + echo ---------------------------------------- |
| 34 | + git status |
| 35 | + echo ---------------------------------------- |
| 36 | + echo git diff |
| 37 | + echo ---------------------------------------- |
| 38 | + git diff |
| 39 | + echo ---------------------------------------- |
| 40 | + echo Troubleshooting |
| 41 | + echo ---------------------------------------- |
| 42 | + echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && mvn -B clean package" |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | +
|
| 46 | + prepare_release: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + needs: [check_code] |
| 49 | + timeout-minutes: 10 |
| 50 | + outputs: |
| 51 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Configure Git |
| 56 | + run: | |
| 57 | + git config --global user.email "[email protected]" |
| 58 | + git config --global user.name "GitHub Actions" |
| 59 | + |
| 60 | + - name: UN-Snap version and output |
| 61 | + id: version |
| 62 | + run: | |
| 63 | + originalVersion=$(grep -Po 'pluginVersion=\K.*' gradle.properties) |
| 64 | + newVersion="$(echo $originalVersion | cut -d '-' -f1)" |
| 65 | + echo "New version: $newVersion" |
| 66 | + sed -i "s/pluginVersion=$originalVersion/pluginVersion=$newVersion/" gradle.properties |
| 67 | + |
| 68 | + version=$newVersion |
| 69 | + echo "release=$version" >> $GITHUB_OUTPUT |
| 70 | + echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT |
| 71 | +
|
| 72 | + echo "Contents of gradle.properties" |
| 73 | + cat gradle.properties |
| 74 | + |
| 75 | + - name: Commit and Push |
| 76 | + run: | |
| 77 | + git add -A |
| 78 | + git commit -m "Release ${{ steps.version.outputs.release }}" |
| 79 | + git push origin |
| 80 | + git tag v${{ steps.version.outputs.release }} |
| 81 | + git push origin --tags |
| 82 | + |
| 83 | + - name: Create Release |
| 84 | + id: create_release |
| 85 | + uses: shogo82148/actions-create-release@e5f206451d4ace2da9916d01f1aef279997f8659 # v1 |
| 86 | + with: |
| 87 | + tag_name: v${{ steps.version.outputs.release }} |
| 88 | + release_name: v${{ steps.version.outputs.release }} |
| 89 | + commitish: master |
| 90 | + body: | |
| 91 | + ## [Changelog](https://github.com/xdev-software/${{ github.event.repository.name }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) |
| 92 | + See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/xdev-software/${{ github.event.repository.name }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information. |
| 93 | +
|
| 94 | + ## Installation |
| 95 | + The plugin is listed on the [Marketplace](https://plugins.jetbrains.com/plugin/pluginId). |
| 96 | + |
| 97 | + Open the plugin Marketplace in your IDE (``File > Settings > Plugins > Marketplace``), search for the plugin and hit the install button. |
| 98 | + |
| 99 | + Alternatively you can also download the jar from the marketplace website. |
| 100 | +
|
| 101 | + publish: |
| 102 | + runs-on: ubuntu-latest |
| 103 | + needs: [prepare_release] |
| 104 | + timeout-minutes: 60 |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + |
| 108 | + - name: Set up JDK |
| 109 | + uses: actions/setup-java@v4 |
| 110 | + with: |
| 111 | + distribution: 'temurin' |
| 112 | + java-version: 21 |
| 113 | + cache: 'gradle' |
| 114 | + |
| 115 | + - name: Init Git and pull |
| 116 | + run: | |
| 117 | + git config --global user.email "[email protected]" |
| 118 | + git config --global user.name "GitHub Actions" |
| 119 | + git pull |
| 120 | + |
| 121 | + - name: Publish Plugin |
| 122 | + env: |
| 123 | + PUBLISH_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_PUBLISH_TOKEN }} |
| 124 | + CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_MARKETPLACE_CERTIFICATE_CHAIN }} |
| 125 | + PRIVATE_KEY: ${{ secrets.JETBRAINS_MARKETPLACE_PRIVATE_KEY }} |
| 126 | + PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_MARKETPLACE_PRIVATE_KEY_PASSWORD }} |
| 127 | + run: ./gradlew publishPlugin --info --stacktrace |
| 128 | + |
| 129 | + - name: Upload plugin files |
| 130 | + uses: actions/upload-artifact@v4 |
| 131 | + with: |
| 132 | + name: plugin-files |
| 133 | + path: build/distributions/* |
| 134 | + |
| 135 | + after_release: |
| 136 | + runs-on: ubuntu-latest |
| 137 | + needs: [publish] |
| 138 | + timeout-minutes: 10 |
| 139 | + steps: |
| 140 | + - uses: actions/checkout@v4 |
| 141 | + |
| 142 | + - name: Init Git and pull |
| 143 | + run: | |
| 144 | + git config --global user.email "[email protected]" |
| 145 | + git config --global user.name "GitHub Actions" |
| 146 | + git pull |
| 147 | + |
| 148 | + - name: Inc Version and SNAP root |
| 149 | + run: | |
| 150 | + originalVersion=$(grep -Po 'pluginVersion=\K.*' gradle.properties) |
| 151 | + newVersion="$(echo $originalVersion | cut -d '-' -f1 | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{$NF=sprintf("%0*d", length($NF), ($NF+1)); print}')-SNAPSHOT" |
| 152 | + echo "New version: $newVersion" |
| 153 | + sed -i "s/pluginVersion=$originalVersion/pluginVersion=$newVersion/" gradle.properties |
| 154 | + |
| 155 | + echo "Contents of gradle.properties" |
| 156 | + cat gradle.properties |
| 157 | +
|
| 158 | + - name: Git Commit and Push |
| 159 | + run: | |
| 160 | + git add -A |
| 161 | + git commit -m "Preparing for next development iteration" |
| 162 | + git push origin |
| 163 | + |
| 164 | + - name: pull-request |
| 165 | + env: |
| 166 | + GH_TOKEN: ${{ github.token }} |
| 167 | + run: | |
| 168 | + gh_pr_up() { |
| 169 | + gh pr create "$@" || gh pr edit "$@" |
| 170 | + } |
| 171 | + gh_pr_up -B "develop" \ |
| 172 | + --title "Sync back" \ |
| 173 | + --body "An automated PR to sync changes back" |
0 commit comments