| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You under the Apache License, Version 2.0 |
| # (the "License"); you may not use this file except in compliance with |
| # the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps: |
| # - Validate Gradle Wrapper. |
| # - Run 'test' and 'verifyPlugin' tasks. |
| # - Run Qodana inspections. |
| # - Run the 'buildPlugin' task and prepare artifact for further tests. |
| # - Run the 'runPluginVerifier' task. |
| # - Create a draft release. |
| # |
| # The workflow is triggered on push and pull_request events. |
| # |
| # GitHub Actions reference: https://help.github.com/en/actions |
| # |
| ## JBIJPPTPL |
| |
| name: Build |
| on: |
| # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests) |
| push: |
| branches: [ main ] |
| # Trigger the workflow on any pull request |
| pull_request: |
| |
| concurrency: |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| cancel-in-progress: true |
| |
| jobs: |
| |
| # Prepare environment and build the plugin |
| build: |
| name: Build |
| runs-on: ubuntu-latest |
| outputs: |
| pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }} |
| steps: |
| |
| # Check out the current repository |
| - name: Fetch Sources |
| uses: actions/checkout@v4 |
| |
| # Validate wrapper |
| - name: Gradle Wrapper Validation |
| uses: gradle/actions/wrapper-validation@v3 |
| |
| # Set up Java environment for the next steps |
| - name: Setup Java |
| uses: actions/setup-java@v4 |
| with: |
| distribution: zulu |
| java-version: 21 |
| |
| # Setup Gradle |
| - name: Setup Gradle |
| uses: gradle/actions/setup-gradle@v4 |
| with: |
| gradle-home-cache-cleanup: true |
| |
| # Set environment variables |
| - name: Export Properties |
| id: properties |
| shell: bash |
| run: | |
| echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT |
| |
| # Build plugin |
| - name: Build plugin |
| run: ./gradlew buildPlugin |
| |
| |
| # Run tests and upload a code coverage report |
| test: |
| name: Test |
| needs: [ build ] |
| runs-on: ubuntu-latest |
| steps: |
| |
| # Check out the current repository |
| - name: Fetch Sources |
| uses: actions/checkout@v4 |
| |
| # Set up Java environment for the next steps |
| - name: Setup Java |
| uses: actions/setup-java@v4 |
| with: |
| distribution: zulu |
| java-version: 21 |
| |
| # Setup Gradle |
| - name: Setup Gradle |
| uses: gradle/actions/setup-gradle@v4 |
| with: |
| gradle-home-cache-cleanup: true |
| |
| # Run tests |
| - name: Run Tests |
| run: ./gradlew check |
| continue-on-error: true |
| |
| # Collect Tests Result of failed tests |
| - name: Collect Tests Result |
| if: ${{ failure() }} |
| uses: actions/upload-artifact@v4 |
| with: |
| name: tests-result |
| path: ${{ github.workspace }}/build/reports/tests |
| |
| # Upload the Kover report to CodeCov |
| - name: Upload Code Coverage Report |
| uses: codecov/codecov-action@v4 |
| with: |
| files: ${{ github.workspace }}/build/reports/kover/report.xml |
| |
| # Run Qodana inspections and provide report |
| inspectCode: |
| name: Inspect code |
| needs: [ build ] |
| runs-on: ubuntu-latest |
| permissions: |
| contents: write |
| checks: write |
| pull-requests: write |
| steps: |
| |
| # Free GitHub Actions Environment Disk Space |
| - name: Maximize Build Space |
| uses: jlumbroso/free-disk-space@v1.3.1 |
| with: |
| tool-cache: false |
| large-packages: false |
| |
| # Check out the current repository |
| - name: Fetch Sources |
| uses: actions/checkout@v4 |
| with: |
| # to check out the actual pull request commit, not the merge commit |
| ref: ${{ github.event.pull_request.head.sha }} |
| # a full history is required for pull request analysis |
| fetch-depth: 0 |
| |
| # Set up the Java environment for the next steps |
| - name: Setup Java |
| uses: actions/setup-java@v4 |
| with: |
| distribution: zulu |
| java-version: 21 |
| |
| # Run Qodana inspections |
| - name: Qodana - Code Inspection |
| uses: JetBrains/qodana-action@v2024.2.6 |
| with: |
| cache-default-branch-only: true |
| |
| # Run plugin structure verification along with IntelliJ Plugin Verifier |
| verify: |
| name: Verify plugin |
| needs: [ build ] |
| runs-on: ubuntu-latest |
| steps: |
| |
| # Free GitHub Actions Environment Disk Space |
| - name: Maximize Build Space |
| uses: jlumbroso/free-disk-space@v1.3.1 |
| with: |
| tool-cache: false |
| large-packages: false |
| |
| # Check out the current repository |
| - name: Fetch Sources |
| uses: actions/checkout@v4 |
| |
| # Set up Java environment for the next steps |
| - name: Setup Java |
| uses: actions/setup-java@v4 |
| with: |
| distribution: zulu |
| java-version: 21 |
| |
| # Setup Gradle |
| - name: Setup Gradle |
| uses: gradle/actions/setup-gradle@v4 |
| with: |
| gradle-home-cache-cleanup: true |
| |
| # Cache Plugin Verifier IDEs |
| - name: Setup Plugin Verifier IDEs Cache |
| uses: actions/cache@v4 |
| with: |
| path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides |
| key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} |
| |
| # Run Verify Plugin task and IntelliJ Plugin Verifier tool |
| - name: Run Plugin Verification tasks |
| run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} |
| |
| # Collect Plugin Verifier Result |
| - name: Collect Plugin Verifier Result |
| if: ${{ always() }} |
| uses: actions/upload-artifact@v4 |
| with: |
| name: pluginVerifier-result |
| path: ${{ github.workspace }}/build/reports/pluginVerifier |
| |
| # Create a pre-release for successful main branch builds |
| createPrerelease: |
| name: Create pre-release |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| needs: [ build, test, inspectCode, verify ] |
| runs-on: ubuntu-latest |
| permissions: |
| contents: write |
| outputs: |
| version: ${{ steps.version.outputs.version }} |
| steps: |
| |
| # Check out the current repository |
| - name: Fetch Sources |
| uses: actions/checkout@v4 |
| |
| # Set up Java environment |
| - name: Setup Java |
| uses: actions/setup-java@v4 |
| with: |
| distribution: zulu |
| java-version: 21 |
| |
| # Setup Gradle |
| - name: Setup Gradle |
| uses: gradle/actions/setup-gradle@v4 |
| with: |
| gradle-home-cache-cleanup: true |
| |
| # Generate version for pre-release |
| - name: Generate Version |
| id: version |
| env: |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| run: | |
| # Get branch number from gradle.properties |
| BRANCH=$(grep "pluginSinceBuild" gradle.properties | cut -d '=' -f2 | tr -d ' ') |
| |
| # Get the latest release version to determine next build number |
| LATEST_RELEASE=$(gh release list --limit 1 --json tagName --jq '.[0].tagName // "v242.18969.1"' 2>/dev/null || echo "v242.18969.1") |
| LATEST_BUILD=$(echo "$LATEST_RELEASE" | sed 's/v[0-9]*\.\([0-9]*\)\.[0-9]*/\1/') |
| |
| # Increment build number for main branch builds |
| BUILD=$((LATEST_BUILD + 1)) |
| |
| # Update pluginVersion in gradle.properties |
| sed -i "s/pluginVersion = [0-9]*\.[0-9]*\.[0-9]*/pluginVersion = ${BRANCH}.${BUILD}.1/" gradle.properties |
| |
| # Get final version and changelog |
| 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 "changelog<<EOF" >> $GITHUB_OUTPUT |
| echo "$CHANGELOG" >> $GITHUB_OUTPUT |
| echo "EOF" >> $GITHUB_OUTPUT |
| |
| # Build plugin with new version |
| - name: Build Plugin |
| run: ./gradlew buildPlugin |
| |
| # Prepare plugin archive content for creating artifact |
| - name: Prepare Plugin Artifact |
| id: artifact |
| shell: bash |
| run: | |
| cd ${{ github.workspace }}/build/distributions |
| FILENAME=`ls *.zip` |
| unzip "$FILENAME" -d content |
| |
| # Use the version-based filename for artifact |
| echo "filename=struts-intellij-plugin-v${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT |
| |
| # Store already-built plugin as an artifact for downloading |
| - name: Upload artifact |
| uses: actions/upload-artifact@v4 |
| with: |
| name: ${{ steps.artifact.outputs.filename }} |
| path: ./build/distributions/content/*/* |
| |
| # Delete previous pre-release if it exists |
| - name: Delete Previous Pre-release |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| run: | |
| # Get the latest pre-release (excluding the current version we're about to create) |
| LATEST_PRERELEASE=$(gh release list --limit 50 --json tagName,isPrerelease --jq '.[] | select(.isPrerelease == true) | .tagName' | head -1 2>/dev/null || echo "") |
| |
| if [ -n "$LATEST_PRERELEASE" ] && [ "$LATEST_PRERELEASE" != "v${{ steps.version.outputs.version }}" ]; then |
| echo "Deleting previous pre-release: $LATEST_PRERELEASE" |
| gh release delete "$LATEST_PRERELEASE" --yes --cleanup-tag |
| else |
| echo "No previous pre-release found to delete" |
| fi |
| |
| # Create a new pre-release |
| - name: Create Pre-release |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| run: | |
| # Find the plugin zip file |
| PLUGIN_ZIP=$(find ./build/distributions -name "*.zip" -type f | head -1) |
| |
| gh release create "v${{ steps.version.outputs.version }}" \ |
| --prerelease \ |
| --title "v${{ steps.version.outputs.version }}" \ |
| --notes "$(cat << 'EOM' |
| 🚀 **Pre-release v${{ steps.version.outputs.version }}** |
| |
| This is an automated pre-release build from the main branch. |
| |
| ## Changes |
| ${{ steps.version.outputs.changelog }} |
| |
| ## Installation |
| Download the plugin zip file and install it manually in IntelliJ IDEA via: |
| `Settings → Plugins → ⚙️ → Install Plugin from Disk...` |
| EOM |
| )" \ |
| "$PLUGIN_ZIP" |