fix #5
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 | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| working-directory: intellij-aicoder | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.properties.outputs.version }} | |
| changelog: ${{ steps.properties.outputs.changelog }} | |
| pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| - name: Make Gradle wrapper executable | |
| run: chmod +x ./gradlew | |
| - name: Fetch Sources | |
| uses: actions/checkout@v4 | |
| - name: Gradle Wrapper Validation | |
| uses: gradle/actions/wrapper-validation@v3 | |
| with: | |
| working-directory: intellij-aicoder | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: zulu | |
| java-version: 17 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| gradle-home-cache-cleanup: true | |
| - name: Export Properties | |
| id: properties | |
| shell: bash | |
| run: | | |
| PROPERTIES="$(./gradlew properties --console=plain -q)" | |
| VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" | |
| CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT | |
| echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
| echo "$CHANGELOG" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Build plugin | |
| run: ./gradlew buildPlugin | |
| - name: Prepare Plugin Artifact | |
| id: artifact | |
| shell: bash | |
| run: | | |
| cd ${{ github.workspace }}/intellij-aicoder/build/distributions | |
| FILENAME=`ls *.zip` | |
| echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.artifact.outputs.filename }} | |
| path: intellij-aicoder/build/distributions/* | |
| test: | |
| name: Test | |
| needs: [ build ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Fetch Sources | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: zulu | |
| java-version: 17 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Run Tests | |
| run: ./gradlew check | |
| - name: Collect Tests Result | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tests-result | |
| path: intellij-aicoder/build/reports/tests | |
| - name: Upload Code Coverage Report | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: intellij-aicoder/build/reports/kover/report.xml | |
| verify: | |
| name: Verify plugin | |
| needs: [ build ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Maximize Build Space | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: false | |
| large-packages: false | |
| - name: Fetch Sources | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: zulu | |
| java-version: 17 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Setup Plugin Verifier IDEs Cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides | |
| key: plugin-verifier-${{ hashFiles('intellij-aicoder/build/listProductsReleases.txt') }} | |
| - name: Run Plugin Verification tasks | |
| run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} | |
| - name: Collect Plugin Verifier Result | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pluginVerifier-result | |
| path: intellij-aicoder/build/reports/pluginVerifier | |
| releaseDraft: | |
| name: Release draft | |
| if: github.event_name != 'pull_request' | |
| needs: [ build, test, verify ] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Fetch Sources | |
| uses: actions/checkout@v4 | |
| - name: Remove Old Release Drafts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh api repos/{owner}/{repo}/releases \ | |
| --jq '.[] | select(.draft == true) | .id' \ | |
| | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} | |
| - name: Create Release Draft | |
| id: create_release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "v${{ needs.build.outputs.version }}" \ | |
| --draft \ | |
| --title "v${{ needs.build.outputs.version }}" \ | |
| --notes "${{ needs.build.outputs.changelog }}" | |
| RELEASE_URL=$(gh release view "v${{ needs.build.outputs.version }}" --json url -q .url) | |
| echo "release_url=$RELEASE_URL" >> $GITHUB_OUTPUT | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ steps.artifact.outputs.filename }} | |
| path: ./artifact | |
| - name: Upload Release Asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.release_url }} | |
| asset_path: ./artifact/intellij-aicoder-${{ needs.build.outputs.version }}/intellij-aicoder-${{ needs.build.outputs.version }}.zip | |
| asset_name: intellij-aicoder-${{ needs.build.outputs.version }}.zip | |
| asset_content_type: application/zip |