From 1ff2b503210022f66163034bdc746fb0fa32076c Mon Sep 17 00:00:00 2001 From: Usman Saleem Date: Thu, 4 Jul 2024 16:32:25 +1000 Subject: [PATCH] build: Add jreleaser plugin (#1) Add jreleaser plugin to manage releases. --- README.md | 2 ++ build.gradle.kts | 70 +++++++++++++++++++++++++++++++++++++-- gradle/libs.versions.toml | 4 ++- 3 files changed, 72 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d6eb40d..0497bd7 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,11 @@ integrate with HSM with PKCS11 interface. SoftHSM is used as a test HSM. Drop the `jar` in the `/plugins` folder under Besu installation. This plugin will expose following additional cli options: +`TBA` ## Linux SoftHSM Setup Following steps are tested on Ubuntu 24.04 LTS. Install following packages. +`TBA` ## Docker setup See Dockerfile for details. diff --git a/build.gradle.kts b/build.gradle.kts index fed570c..b98c88b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,16 @@ +import org.jreleaser.model.Active +import org.jreleaser.model.Distribution +import org.jreleaser.model.UpdateSection + plugins { `java-library` alias(libs.plugins.spotless) alias(libs.plugins.jgitver) + alias(libs.plugins.jreleaser) } +project.group = "info.usmans.tools" + repositories { // Use Maven Central for resolving dependencies. mavenCentral() @@ -38,7 +45,64 @@ spotless { kotlinGradle { ktfmt() } } -jgitver { - nonQualifierBranches = "main" - useDirty = true +jgitver { nonQualifierBranches = "main" } + +tasks.register("printVersion") { + group = "Help" + description = "Prints the project version" + doLast { println("Version: ${project.version}") } +} + +tasks.jar { + manifest { + attributes( + mapOf("Implementation-Title" to project.name, "Implementation-Version" to project.version)) + } +} + +jreleaser { + dependsOnAssemble = true + project { + description.set("Besu PKCS11-SoftHSM plugin") + authors.set(listOf("Usman Saleem")) + license.set("(Apache-2.0 OR MIT)") + inceptionYear.set("2024") + copyright.set("2024, Usman Saleem") + links { + homepage.set("https://github.com/usmansaleem/besu-pkcs11-plugin") + documentation.set("https://github.com/usmansaleem/besu-pkcs11-plugin") + } + } + + distributions { + create("besu-pkcs11-plugin") { + distributionType.set(Distribution.DistributionType.SINGLE_JAR) + artifact { + path.set(layout.buildDirectory.file("libs/{{distributionName}}-{{projectVersion}}.jar")) + } + } + } + + release { + github { + repoOwner = "usmansaleem" + token = "__DO_NOT_SET_HERE__" + // append artifacts to an existing release with matching tag + update { + enabled = true + sections.set(listOf(UpdateSection.ASSETS, UpdateSection.TITLE, UpdateSection.BODY)) + } + // We need to create tag manually because our version calculation depends on it. + skipTag = true + changelog { + formatted.set(Active.ALWAYS) + preset.set("conventional-commits") + contributors { + enabled.set(true) + format.set( + "- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}") + } + } + } + } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 257f732..36fba47 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ spotless = "6.25.0" slf4j = "2.0.13" bouncy-castle = "1.78.1" jgitver = "0.10.0-rc03" +jreleaser = "1.13.1" [libraries] junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" } @@ -18,4 +19,5 @@ bcprov = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "bouncy-cas [plugins] spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } -jgitver = { id = "fr.brouillard.oss.gradle.jgitver", version.ref = "jgitver" } \ No newline at end of file +jgitver = { id = "fr.brouillard.oss.gradle.jgitver", version.ref = "jgitver" } +jreleaser = { id = "org.jreleaser", version.ref = "jreleaser"} \ No newline at end of file