Skip to content

Commit dcbc3e4

Browse files
Thomas Scharketscharke
authored andcommitted
chore: Automatically build and release project
1 parent e8c9c82 commit dcbc3e4

File tree

8 files changed

+156
-22
lines changed

8 files changed

+156
-22
lines changed

.github/actions/build/action.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build HTML-Attribute-Folder
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Setup Java
7+
uses: actions/setup-java@v4
8+
with:
9+
distribution: 'oracle'
10+
java-version: ${{ inputs.java_version }}
11+
cache: 'gradle'
12+
13+
- name: Setup Gradle
14+
uses: gradle/actions/setup-gradle@v4
15+
with:
16+
cache-disabled: true
17+
18+
- name: Build, Tests and Verify Plugin
19+
shell: bash
20+
run: |
21+
./gradlew buildPlugin verifyPlugin check \
22+
-PpluginVersion=${{ inputs.version }} \
23+
--no-configuration-cache \
24+
--no-build-cache \
25+
--no-daemon \
26+
--max-workers=1 \
27+
-Dorg.gradle.internal.http.socketTimeout=120000 \
28+
-Dorg.gradle.internal.http.connectionTimeout=120000 \
29+
-Dorg.gradle.internal.network.retry.max.attempts=10
30+
env:
31+
GRADLE_USER_HOME: /mnt/gradle-cache
32+
GRADLE_OPTS: "-Dorg.gradle.configuration-cache=false"
33+
34+
inputs:
35+
version:
36+
description: Version of the Release
37+
required: true
38+
java_version:
39+
description: Java version to use
40+
required: false
41+
default: "21"

.github/workflows/buildRelease.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Build and Release HTML-Attribute-Folder
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- name: Maximize Build Space
14+
uses: easimon/maximize-build-space@v10
15+
with:
16+
root-reserve-mb: 2048
17+
swap-size-mb: 1024
18+
remove-dotnet: true
19+
remove-android: true
20+
remove-haskell: true
21+
build-mount-path: /mnt/gradle-cache
22+
23+
- name: Checkout project sources
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
fetch-tags: true
28+
ref: ${{ github.ref }}
29+
30+
- name: Get the version
31+
id: versions
32+
run: echo "TAGGED_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
33+
34+
- name: Validate version
35+
id: check_version
36+
run: |
37+
if [[ "${{ steps.versions.outputs.TAGGED_VERSION }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
38+
echo "valid=true" >> $GITHUB_OUTPUT
39+
else
40+
echo "valid=false" >> $GITHUB_OUTPUT
41+
fi
42+
43+
- name: Build and Test
44+
uses: ./.github/actions/build
45+
with:
46+
version: ${{ steps.versions.outputs.TAGGED_VERSION }}
47+
48+
- name: Create GitHub Release
49+
uses: ncipollo/release-action@v1
50+
with:
51+
token: ${{ secrets.GITHUB_TOKEN }}
52+
artifacts: "build/distributions/html-attribute-folder-*.zip"
53+
name: "Release v${{ steps.versions.outputs.TAGGED_VERSION }}"
54+
tag: "v${{ steps.versions.outputs.TAGGED_VERSION }}"
55+
prerelease: ${{ steps.check_version.outputs.valid != 'true' }}
56+
allowUpdates: true
57+
58+
- name: Create IntelliJ's Marketplace Release
59+
# Publish only valid semantic (real) versions
60+
if: steps.check_version.outputs.valid == 'true'
61+
run: ./gradlew publishPlugin -PpluginVersion=${{ steps.versions.outputs.TAGGED_VERSION }} --no-configuration-cache --no-build-cache
62+
env:
63+
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
64+
GRADLE_USER_HOME: /mnt/gradle-cache
65+
GRADLE_OPTS: "-Dorg.gradle.configuration-cache=false -Dorg.gradle.caching=false"
66+
67+
- name: Cleanup Tag on Failure
68+
if: failure()
69+
run: |
70+
echo "Build failed. Deleting tag v${{ steps.versions.outputs.TAGGED_VERSION }}..."
71+
git push --delete origin v${{ steps.versions.outputs.TAGGED_VERSION }}
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle.kts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,49 @@
1-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2-
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
3-
41
fun properties(key: String) = providers.gradleProperty(key)
52

63
plugins {
74
id("java")
8-
id("org.jetbrains.kotlin.jvm") version "2.2.0"
9-
id("org.jetbrains.intellij.platform") version "2.5.0"
5+
id("org.jetbrains.kotlin.jvm") version "2.1.0"
6+
id("org.jetbrains.intellij.platform") version "2.10.5"
107
}
118

129
group = properties("pluginGroup").get()
1310
version = properties("pluginVersion").get()
1411

1512
repositories {
13+
gradlePluginPortal()
14+
google()
1615
mavenCentral()
1716

1817
intellijPlatform {
1918
defaultRepositories()
19+
marketplace()
20+
jetbrainsRuntime()
2021
}
2122
}
2223

2324
dependencies {
2425
intellijPlatform {
25-
val type = properties("platformType").get()
26-
val version = properties("platformVersion").get()
26+
val type = providers.gradleProperty("platformType").getOrElse("IU")
27+
val version = providers.gradleProperty("platformVersion").getOrElse("2024.3")
2728
create(type, version)
2829

29-
testFramework(TestFrameworkType.Platform)
30+
pluginVerifier()
31+
32+
testFramework(org.jetbrains.intellij.platform.gradle.TestFrameworkType.Platform)
3033
bundledPlugin("JavaScript")
3134
}
3235

3336
testImplementation(kotlin("test"))
3437
}
3538

39+
intellijPlatform {
40+
pluginVerification {
41+
ides {
42+
create(org.jetbrains.intellij.platform.gradle.IntelliJPlatformType.IntellijIdeaCommunity, "2024.3")
43+
}
44+
}
45+
}
46+
3647
tasks {
3748
// Set the JVM compatibility versions
3849
withType<JavaCompile> {
@@ -41,7 +52,9 @@ tasks {
4152
}
4253
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
4354
compilerOptions {
44-
jvmTarget.set(JvmTarget.fromTarget(properties("javaVersion").get()))
55+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(properties("javaVersion").get()))
56+
// Deactivate K2 to avoid SpillingKt problems during the verification phase
57+
freeCompilerArgs.add("-Xuse-k2=false")
4558
}
4659
}
4760

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ org.gradle.caching=true
77

88
pluginName=html-attribute-folder
99
pluginGroup=dev.zbinski
10-
pluginVersion=1.4.0
10+
# Do not modify the version here, it's for locale builds only
11+
# Git-Tags set the release version
12+
pluginVersion=0.0.0-dev
1113
platformVersion=2025.3
1214
# @see https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-types.html#IntelliJPlatformType
1315
platformType=IU
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/kotlin/dev/zbinski/htmlattributefolder/AttributeFolderAction.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ class AttributeFolderAction : AnAction() {
1111

1212
private fun getFoldRegionsForRelevantAttributes(foldRegions: Array<FoldRegion>): List<FoldRegion> {
1313
val relevantAttributes = settings.attributes
14+
val result = mutableListOf<FoldRegion>()
1415

1516
// Identifying a fold based on its "groupName"/"debugName" is possible because all folds relevant
1617
// to us have a self-defined `FoldingGroup` including the "groupname"/"debugName".
1718
// (see ->AttributeFolder.buildFoldRegions:37)
18-
return foldRegions.filter {
19-
val group = it.group
19+
for (region in foldRegions) {
20+
val group = region.group
2021
// The `group.toString()` returns the "groupName"/"debugName"
21-
group != null && relevantAttributes.contains(group.toString())
22+
if (group != null && relevantAttributes.contains(group.toString())) {
23+
result.add(region)
24+
}
2225
}
23-
26+
return result
2427
}
2528

2629
private fun performFoldOperation(fold: FoldRegion) {

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name -->
88
<name>HTML Attribute Folder</name>
99

10-
<version>1.4.0</version>
11-
1210
<!-- A displayed Vendor name or Organization ID displayed on the Plugins Page. -->
1311
<vendor email="dawid@zbinski.dev" url="https://zbinski.dev">Dawid Zbiński</vendor>
1412

@@ -29,7 +27,7 @@
2927
<depends>com.intellij.modules.platform</depends>
3028
<depends>com.intellij.modules.lang</depends>
3129
<depends>com.intellij.modules.xml</depends>
32-
<depends optional="true">com.intellij.modules.javascript</depends>
30+
<depends optional="true" config-file="withJavaScript.xml">com.intellij.modules.javascript</depends>
3331

3432
<!-- Extension points defined by the plugin.
3533
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
@@ -40,10 +38,6 @@
4038
<lang.foldingBuilder language="XML" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
4139
<lang.foldingBuilder language="HTML" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
4240
<lang.foldingBuilder language="XHTML" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
43-
<lang.foldingBuilder language="TypeScript" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
44-
<lang.foldingBuilder language="TypeScript JSX" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
45-
<lang.foldingBuilder language="JavaScript" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
46-
<lang.foldingBuilder language="JavaScript JSX" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
4741
<lang.foldingBuilder language="RHTML" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
4842

4943
<projectConfigurable parentId="tools"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<idea-plugin>
2+
<extensions defaultExtensionNs="com.intellij">
3+
<lang.foldingBuilder language="TypeScript" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
4+
<lang.foldingBuilder language="TypeScript JSX" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
5+
<lang.foldingBuilder language="JavaScript" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
6+
<lang.foldingBuilder language="JavaScript JSX" implementationClass="dev.zbinski.htmlattributefolder.AttributeFolder"/>
7+
</extensions>
8+
</idea-plugin>

0 commit comments

Comments
 (0)