Skip to content

Commit 59273dc

Browse files
chore: bump version for maven central publishing
1 parent fc41c63 commit 59273dc

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed

buildSrc/src/main/kotlin/buildlogic.java-common-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ testing {
7070
}
7171
}
7272

73-
val projectVersion by extra("2.0.12")
73+
val projectVersion by extra("2.0.13")
7474

7575
public val jdkVersion = 24
7676
// Apply a specific Java toolchain to ease working on different environments.

native/build.gradle.kts

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import java.io.File
2+
import java.util.*
23

34
plugins {
45
// Apply the application plugin to add support for building a CLI application in Java.
56
id("buildlogic.java-library-conventions")
67
id("maven-publish")
8+
signing
79
}
810

911
repositories {
@@ -102,12 +104,32 @@ publishing {
102104
repositories {
103105
// Publish to GitHub Packages
104106
// https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-java-packages-with-gradle
105-
maven {
106-
name = "GitHubPackages"
107-
url = uri("https://maven.pkg.github.com/briancorbinxyz/overengineering-tictactoe")
108-
credentials {
109-
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
110-
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
107+
val targetRepo: String? = findProperty("repo") as String?
108+
if (targetRepo == null || targetRepo == "Sonatype") {
109+
maven {
110+
name = "Sonatype"
111+
url = uri(
112+
if (version.toString().endsWith("SNAPSHOT"))
113+
//"https://s01.oss.sonatype.org/content/repositories/snapshots/"
114+
"https://central.sonatype.com/repository/maven-snapshots/"
115+
else
116+
// "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
117+
"https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2"
118+
)
119+
credentials {
120+
username = project.findProperty("sonatype.user") as String? ?: System.getenv("SONATYPE_USER")
121+
password = project.findProperty("sonatype.key") as String? ?: System.getenv("SONATYPE_TOKEN")
122+
}
123+
}
124+
}
125+
if (targetRepo == null || targetRepo == "GitHubPackages") {
126+
maven {
127+
name = "GitHubPackages"
128+
url = uri("https://maven.pkg.github.com/briancorbinxyz/overengineering-tictactoe")
129+
credentials {
130+
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
131+
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
132+
}
111133
}
112134
}
113135
}
@@ -142,3 +164,35 @@ publishing {
142164
}
143165
}
144166
}
167+
fun decodeKey(raw: String): String =
168+
if (raw.contains("-----BEGIN PGP PRIVATE KEY BLOCK-----")) {
169+
raw
170+
} else {
171+
String(Base64.getDecoder().decode(raw))
172+
}
173+
174+
val rawSigningKey = System.getenv("SIGNING_KEY") ?: findProperty("signing.key") as String?
175+
val signingKey = rawSigningKey?.let(::decodeKey)
176+
177+
val signingPassword = System.getenv("SIGNING_PASSWORD") ?: findProperty("signing.password") as String?
178+
val signingKeyId = System.getenv("SIGNING_KEY_ID") ?: findProperty("signing.keyId") as String?
179+
180+
val isPublishing = gradle.startParameter.taskNames.any { it.contains("publish", ignoreCase = true) }
181+
182+
val shouldSign = signingKey != null && signingPassword != null
183+
184+
logger.lifecycle("🔐 Signing check:")
185+
logger.lifecycle(" • isPublishing: $isPublishing")
186+
logger.lifecycle(" • signingKeyId: ${signingKeyId != null}")
187+
logger.lifecycle(" • signingKey present: ${signingKey != null}")
188+
logger.lifecycle(" • signingPassword present: ${signingPassword != null}")
189+
logger.lifecycle(" • shouldSign: $shouldSign")
190+
if (isPublishing && shouldSign) {
191+
signing {
192+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
193+
sign(configurations.runtimeElements.get())
194+
}
195+
}
196+
197+
198+

0 commit comments

Comments
 (0)