Skip to content

Commit 8afa22e

Browse files
authored
Merge pull request #50 from maize-genetics/fix-maven-release
Fix maven release
2 parents 0afbc72 + 27b45a9 commit 8afa22e

File tree

2 files changed

+68
-43
lines changed

2 files changed

+68
-43
lines changed

.github/workflows/run-publish-maven.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ jobs:
4141
run: chmod +x ./gradlew
4242

4343
- name: Publish to Maven Central Repository
44-
run: conda run ./gradlew clean publishToSonatype closeAndReleaseSonatypeStagingRepository --no-daemon
44+
run: conda run --no-capture-output bash -c "./gradlew jreleaserConfig && ./gradlew clean && ./gradlew publish && ./gradlew jreleaserFullRelease -Dorg.gradle.jvmargs=\"-Xmx8g\""
4545
env:
4646
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }}
4747
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_PASSWORD }}
4848
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
4949
GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }}
50+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SIGNING_KEY }}
51+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSWORD }}
52+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
53+
JRELEASER_GITHUB_TOKEN: ${{ secrets.BIOKOTLINMAVEN }}
54+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
55+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
56+

build.gradle.kts

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
import org.jreleaser.model.Active
23
import java.io.ByteArrayOutputStream
34
import java.nio.file.Files
45
import java.nio.file.Paths
56
import kotlin.io.path.isRegularFile
67
import kotlin.jvm.optionals.getOrNull
78

8-
// Note Kotlin version needs to be updated in both the buildscript and plugins.
9-
// Dependencies will follow the buildscript
10-
9+
// This is used to get the version from the git tag
10+
// The version is expected to be in the format X.Y.Z
11+
// JReleaser will use this version to create the release
1112
fun getVersionName(): String {
1213
val stdout = ByteArrayOutputStream()
1314
exec {
1415
commandLine = listOf("git", "describe", "--tags", "--abbrev=0")
1516
standardOutput = stdout
1617
}
17-
return stdout.toString().trim()
18+
val versionStr = stdout.toString().trim().removePrefix("v").removePrefix("V")
19+
val parts = versionStr.split('.')
20+
val normalizedStr = when (parts.size) {
21+
0 -> throw IllegalArgumentException("Version string is empty")
22+
1 -> "${parts[0]}.0.0"
23+
2 -> "${parts[0]}.${parts[1]}.0"
24+
else -> versionStr
25+
}
26+
return normalizedStr
1827
}
1928

2029
group = "org.biokotlin"
@@ -25,20 +34,8 @@ This build script is need to use the early access
2534
*/
2635
buildscript {
2736
val kotlinVersion by extra("1.9.24")
28-
29-
repositories {
30-
mavenCentral()
31-
gradlePluginPortal()
32-
}
33-
34-
dependencies {
35-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
36-
classpath(kotlin("serialization", version = kotlinVersion))
37-
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
38-
}
3937
}
4038

41-
4239
plugins {
4340
val kotlinVersion = "1.9.24"
4441
java
@@ -56,22 +53,17 @@ plugins {
5653
`java-library`
5754
`maven-publish`
5855
signing
59-
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
60-
}
61-
apply {
62-
plugin("kotlinx-serialization")
63-
plugin("org.jetbrains.dokka")
56+
id("org.jreleaser") version "1.18.0"
6457
}
6558

66-
6759
repositories {
6860
mavenCentral()
6961
gradlePluginPortal()
7062
maven("https://maven.imagej.net/content/groups/public/")
7163
maven("https://jitpack.io")
72-
maven("https://dl.bintray.com/kotlin/kotlin-eap")
73-
maven("https://kotlin.bintray.com/kotlinx")
74-
maven("https://oss.sonatype.org/content/repositories/snapshots/")
64+
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/eap")
65+
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlinx")
66+
7567
}
7668

7769
dependencies {
@@ -121,13 +113,14 @@ dependencies {
121113
testImplementation("io.kotest:kotest-$it-jvm:$kotestVersion")
122114
}
123115

124-
//consider adding Kotlintest
125116
}
126-
//This is used for code generation for DataFrame Schema, however, it does not work
127-
//https://github.com/Kotlin/dataframe/tree/eb9ec4fb90f906f6a98e69b9c5a0369009d34bbb/plugins/gradle/codegen
128-
//kotlin.sourceSets.getByName("main").kotlin.srcDir("build/generated/ksp/main/kotlin/")
117+
118+
// This is used for code generation for DataFrame Schema, however, it does not work
119+
// https://github.com/Kotlin/dataframe/tree/eb9ec4fb90f906f6a98e69b9c5a0369009d34bbb/plugins/gradle/codegen
120+
// kotlin.sourceSets.getByName("main").kotlin.srcDir("build/generated/ksp/main/kotlin/")
129121

130122
java {
123+
// withJavadocJar()
131124
withSourcesJar()
132125
}
133126

@@ -408,6 +401,7 @@ publishing {
408401

409402
pom {
410403
name.set("BioKotlin")
404+
artifactId = "biokotlin"
411405
description.set("BioKotlin aims to be a high-performance bioinformatics library that brings the power and speed of compiled programming languages to scripting and big data environments.")
412406
url.set("http://www.biokotlin.org/")
413407
licenses {
@@ -467,27 +461,51 @@ publishing {
467461
}
468462
}
469463
}
464+
465+
repositories {
466+
maven {
467+
url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI()
468+
}
469+
}
470470
}
471471

472472
signing {
473473
useInMemoryPgpKeys(System.getenv("GPG_SIGNING_KEY"), System.getenv("GPG_SIGNING_PASSWORD"))
474474
sign(publishing.publications["maven"])
475475
}
476476

477-
tasks.javadoc {
478-
dependsOn("dokkaJavadoc")
479-
if (JavaVersion.current().isJava9Compatible) {
480-
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
477+
jreleaser {
478+
signing {
479+
active.set(Active.ALWAYS)
480+
armored.set(true)
481+
setMode("MEMORY")
481482
}
482-
}
483-
484-
nexusPublishing {
485-
repositories {
486-
sonatype()
483+
deploy {
484+
active.set(Active.ALWAYS)
485+
release {
486+
github {
487+
skipRelease = true
488+
skipTag = true
489+
}
490+
}
491+
maven {
492+
active.set(Active.ALWAYS)
493+
mavenCentral {
494+
signing {
495+
active.set(Active.ALWAYS)
496+
armored.set(true)
497+
setMode("MEMORY")
498+
}
499+
create("sonatype") {
500+
active.set(Active.ALWAYS)
501+
url.set("https://central.sonatype.com/api/v1/publisher")
502+
stagingRepository("build/staging-deploy")
503+
}
504+
}
505+
}
487506
}
488507
}
489508

490-
tasks.publish {
491-
dependsOn(dokkaJar)
492-
mustRunAfter(dokkaJar)
493-
}
509+
tasks.named("publish") {
510+
dependsOn("dokkaJar", "sourcesJar")
511+
}

0 commit comments

Comments
 (0)