Build and Publish #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| publish: | |
| description: 'Publish the plugin to JetBrains Marketplace' | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| build: | |
| name: "Build & Publish" | |
| runs-on: windows-2022 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Get Version | |
| id: get_version | |
| shell: pwsh | |
| run: | | |
| $version = Select-String -Path gradle.properties -Pattern "PluginVersion=(.*)" | ForEach-Object { $_.Matches.Groups[1].Value } | |
| echo "VERSION=$version" >> $env:GITHUB_OUTPUT | |
| - name: Build Plugin | |
| run: ./gradlew buildPlugin | |
| - name: Run Tests | |
| run: ./gradlew testDotNet | |
| - name: Create GitHub Release | |
| if: github.event_name == 'workflow_dispatch' && inputs.publish == true | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.get_version.outputs.VERSION }} | |
| name: v${{ steps.get_version.outputs.VERSION }} | |
| files: | | |
| output/*.zip | |
| output/*.nupkg | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish Plugin | |
| if: github.event_name == 'workflow_dispatch' && inputs.publish == true | |
| shell: pwsh | |
| env: | |
| PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} | |
| run: | | |
| if (-not $env:PUBLISH_TOKEN) { | |
| Write-Error "PUBLISH_TOKEN secret is not set. Please add it to GitHub Secrets." | |
| exit 1 | |
| } | |
| ./gradlew publishPlugin -PPublishToken="$env:PUBLISH_TOKEN" |