Skip to content

Commit

Permalink
Add change notes to plugin XML (#85)
Browse files Browse the repository at this point in the history
The `build.gradle.kts` file is updated to parse change notes from an environment variable and add it to the plugin XML. This change helps to automate the process of updating change notes. The GitHub workflow file has also been updated to pass the release body as change notes for each build.

Co-authored-by: Lamberto Basti <[email protected]>
Co-authored-by: Fabrizio Scarponi <[email protected]>
  • Loading branch information
3 people authored Feb 21, 2024
1 parent ef4ee61 commit 4581ca3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish to Marketplace

on:
release:
types: [published]
types: [ published ]

jobs:
publish:
Expand All @@ -25,3 +25,4 @@ jobs:
GRADLE_ENTERPRISE_KEY: ${{ secrets.GRADLE_ENTERPRISE_KEY }}
MAVEN_SPACE_PASSWORD: ${{ secrets.MAVEN_SPACE_PASSWORD }}
MAVEN_SPACE_USERNAME: ${{ secrets.MAVEN_SPACE_USERNAME }}
CHANGE_NOTES: ${{ github.event.release.body }}
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ dependencies {
implementation(packageSearchCatalog.kotlinx.serialization.json)
implementation("com.squareup:kotlinpoet:1.14.2")
implementation("io.github.pdvrieze.xmlutil:serialization:0.86.2")
implementation("com.vladsch.flexmark:flexmark-all:0.64.8")
}
19 changes: 15 additions & 4 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
@file:Suppress("UnstableApiUsage")

import com.vladsch.flexmark.html.HtmlRenderer
import com.vladsch.flexmark.parser.Parser
import java.lang.System.getenv
import kotlin.math.max
import org.jetbrains.intellij.tasks.PublishPluginTask
import org.jetbrains.kotlin.util.prefixIfNot
import org.jetbrains.kotlin.util.suffixIfNot
import org.jetbrains.packagesearch.gradle.lafFile
import org.jetbrains.packagesearch.gradle.logCategoriesFile
import org.jetbrains.packagesearch.gradle.patchLafFile
Expand Down Expand Up @@ -103,14 +108,20 @@ tasks {
runtimeClasspathFiles = tooling
}

val runNumber = System.getenv("RUN_NUMBER")?.toInt() ?: 0
val runAttempt = System.getenv("RUN_ATTEMPT")?.toInt() ?: 0
val runNumber = getenv("RUN_NUMBER")?.toInt() ?: 0
val runAttempt = getenv("RUN_ATTEMPT")?.toInt() ?: 0
val snapshotMinorVersion = max(0, runNumber + runAttempt - 1)
val versionString = project.version.toString()

patchPluginXml {
pluginId = pkgsPluginId
version = versionString.replace("-SNAPSHOT", ".$snapshotMinorVersion")
changeNotes = getenv("CHANGE_NOTES")
?.let { Parser.builder().build().parse(it) }
?.let { HtmlRenderer.builder().build().render(it) }
?.prefixIfNot("<![CDATA[")
?.suffixIfNot("]]>")

}
val buildShadowPlugin by registering(Zip::class) {
group = "intellij"
Expand All @@ -132,15 +143,15 @@ tasks {
toolboxEnterprise = true
host = "https://tbe.labs.jb.gg/"
token = project.properties["toolboxEnterpriseToken"]?.toString()
?: System.getenv("TOOLBOX_ENTERPRISE_TOKEN")
?: getenv("TOOLBOX_ENTERPRISE_TOKEN")
channels = listOf("Stable")
}

register<PublishPluginTask>("publishShadowPluginToMarketplace") {
group = "publishing"
distributionFile = buildShadowPlugin.flatMap { it.archiveFile }
token = project.properties["marketplaceToken"]?.toString()
?: System.getenv("MARKETPLACE_TOKEN")
?: getenv("MARKETPLACE_TOKEN")
}

}

0 comments on commit 4581ca3

Please sign in to comment.