diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..5e4127d --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,41 @@ +name: Build HTML-Attribute-Folder + +runs: + using: "composite" + steps: + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'oracle' + java-version: ${{ inputs.java_version }} + cache: 'gradle' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + cache-disabled: true + + - name: Build, Tests and Verify Plugin + shell: bash + run: | + ./gradlew buildPlugin verifyPlugin check \ + -PpluginVersion=${{ inputs.version }} \ + --no-configuration-cache \ + --no-build-cache \ + --no-daemon \ + --max-workers=1 \ + -Dorg.gradle.internal.http.socketTimeout=120000 \ + -Dorg.gradle.internal.http.connectionTimeout=120000 \ + -Dorg.gradle.internal.network.retry.max.attempts=10 + env: + GRADLE_USER_HOME: /mnt/gradle-cache + GRADLE_OPTS: "-Dorg.gradle.configuration-cache=false" + +inputs: + version: + description: Version of the Release + required: true + java_version: + description: Java version to use + required: false + default: "21" diff --git a/.github/workflows/buildRelease.yml b/.github/workflows/buildRelease.yml new file mode 100644 index 0000000..5446553 --- /dev/null +++ b/.github/workflows/buildRelease.yml @@ -0,0 +1,73 @@ +name: Build and Release HTML-Attribute-Folder +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Maximize Build Space + uses: easimon/maximize-build-space@v10 + with: + root-reserve-mb: 2048 + swap-size-mb: 1024 + remove-dotnet: true + remove-android: true + remove-haskell: true + build-mount-path: /mnt/gradle-cache + + - name: Checkout project sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + ref: ${{ github.ref }} + + - name: Get the version + id: versions + run: echo "TAGGED_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Validate version + id: check_version + run: | + if [[ "${{ steps.versions.outputs.TAGGED_VERSION }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "valid=true" >> $GITHUB_OUTPUT + else + echo "valid=false" >> $GITHUB_OUTPUT + fi + + - name: Build and Test + uses: ./.github/actions/build + with: + version: ${{ steps.versions.outputs.TAGGED_VERSION }} + + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + artifacts: "build/distributions/html-attribute-folder-*.zip" + name: "Release v${{ steps.versions.outputs.TAGGED_VERSION }}" + tag: "v${{ steps.versions.outputs.TAGGED_VERSION }}" + prerelease: ${{ steps.check_version.outputs.valid != 'true' }} + allowUpdates: true + + - name: Create IntelliJ's Marketplace Release + # Publish only valid semantic (real) versions + if: steps.check_version.outputs.valid == 'true' + run: ./gradlew publishPlugin -PpluginVersion=${{ steps.versions.outputs.TAGGED_VERSION }} --no-configuration-cache --no-build-cache + env: + PUBLISH_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }} + GRADLE_USER_HOME: /mnt/gradle-cache + GRADLE_OPTS: "-Dorg.gradle.configuration-cache=false -Dorg.gradle.caching=false" + + - name: Cleanup Tag on Failure + if: failure() + run: | + echo "Build failed. Deleting tag v${{ steps.versions.outputs.TAGGED_VERSION }}..." + git push --delete origin v${{ steps.versions.outputs.TAGGED_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index f205894..012840e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,38 +1,49 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.intellij.platform.gradle.TestFrameworkType - fun properties(key: String) = providers.gradleProperty(key) plugins { id("java") - id("org.jetbrains.kotlin.jvm") version "2.2.0" - id("org.jetbrains.intellij.platform") version "2.5.0" + id("org.jetbrains.kotlin.jvm") version "2.1.0" + id("org.jetbrains.intellij.platform") version "2.10.5" } group = properties("pluginGroup").get() version = properties("pluginVersion").get() repositories { + gradlePluginPortal() + google() mavenCentral() intellijPlatform { defaultRepositories() + marketplace() + jetbrainsRuntime() } } dependencies { intellijPlatform { - val type = properties("platformType").get() - val version = properties("platformVersion").get() + val type = providers.gradleProperty("platformType").getOrElse("IU") + val version = providers.gradleProperty("platformVersion").getOrElse("2024.3") create(type, version) - testFramework(TestFrameworkType.Platform) + pluginVerifier() + + testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform) bundledPlugin("JavaScript") } testImplementation(kotlin("test")) } +intellijPlatform { + pluginVerification { + ides { + create(org.jetbrains.intellij.platform.gradle.IntelliJPlatformType.IntellijIdeaCommunity, "2024.3") + } + } +} + tasks { // Set the JVM compatibility versions withType { @@ -41,7 +52,9 @@ tasks { } withType { compilerOptions { - jvmTarget.set(JvmTarget.fromTarget(properties("javaVersion").get())) + jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(properties("javaVersion").get())) + // Deactivate K2 to avoid SpillingKt problems during the verification phase + freeCompilerArgs.add("-Xuse-k2=false") } } diff --git a/gradle.properties b/gradle.properties index 0cbab33..ca66fde 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,9 @@ org.gradle.caching=true pluginName=html-attribute-folder pluginGroup=dev.zbinski -pluginVersion=1.4.0 +# Do not modify the version here, it's for locale builds only +# Git-Tags set the release version +pluginVersion=0.0.0-dev platformVersion=2025.3 # @see https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-types.html#IntelliJPlatformType platformType=IU diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e382118..2733ed5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/dev/zbinski/htmlattributefolder/AttributeFolderAction.kt b/src/main/kotlin/dev/zbinski/htmlattributefolder/AttributeFolderAction.kt index a57b772..2f17394 100644 --- a/src/main/kotlin/dev/zbinski/htmlattributefolder/AttributeFolderAction.kt +++ b/src/main/kotlin/dev/zbinski/htmlattributefolder/AttributeFolderAction.kt @@ -11,16 +11,19 @@ class AttributeFolderAction : AnAction() { private fun getFoldRegionsForRelevantAttributes(foldRegions: Array): List { val relevantAttributes = settings.attributes + val result = mutableListOf() // Identifying a fold based on its "groupName"/"debugName" is possible because all folds relevant // to us have a self-defined `FoldingGroup` including the "groupname"/"debugName". // (see ->AttributeFolder.buildFoldRegions:37) - return foldRegions.filter { - val group = it.group + for (region in foldRegions) { + val group = region.group // The `group.toString()` returns the "groupName"/"debugName" - group != null && relevantAttributes.contains(group.toString()) + if (group != null && relevantAttributes.contains(group.toString())) { + result.add(region) + } } - + return result } private fun performFoldOperation(fold: FoldRegion) { diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index c2949ea..41413c2 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -7,8 +7,6 @@ Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name --> HTML Attribute Folder - 1.4.0 - Dawid ZbiƄski @@ -29,7 +27,7 @@ com.intellij.modules.platform com.intellij.modules.lang com.intellij.modules.xml - com.intellij.modules.javascript + com.intellij.modules.javascript @@ -40,10 +38,6 @@ - - - - + + + + + + +