From 4581ca3c366619833da44bd510a6ea9e286b3620 Mon Sep 17 00:00:00 2001 From: Lamberto Basti Date: Wed, 21 Feb 2024 12:30:03 +0100 Subject: [PATCH] Add change notes to plugin XML (#85) 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 Co-authored-by: Fabrizio Scarponi <36624359+fscarponi@users.noreply.github.com> --- .github/workflows/publish-release.yml | 3 ++- buildSrc/build.gradle.kts | 1 + plugin/build.gradle.kts | 19 +++++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index dbede255..eb9b81db 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -2,7 +2,7 @@ name: Publish to Marketplace on: release: - types: [published] + types: [ published ] jobs: publish: @@ -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 }} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 17199620..b0c30127 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -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") } diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 1fede8b2..ca82d93a 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -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 @@ -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("") + } val buildShadowPlugin by registering(Zip::class) { group = "intellij" @@ -132,7 +143,7 @@ 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") } @@ -140,7 +151,7 @@ tasks { group = "publishing" distributionFile = buildShadowPlugin.flatMap { it.archiveFile } token = project.properties["marketplaceToken"]?.toString() - ?: System.getenv("MARKETPLACE_TOKEN") + ?: getenv("MARKETPLACE_TOKEN") } }