Skip to content

Commit 49495db

Browse files
Accept Gradle properties for Sonatype + signing credentials (#4)
* Accept Gradle properties for Sonatype + signing credentials Why: the HubSpotEngineering/oss-release Gradle release flow exports credentials as ORG_GRADLE_PROJECT_mavenCentralUsername/Password and ORG_GRADLE_PROJECT_signingInMemoryKey{,Id,Password}. The current publish/signing config only reads SONATYPE_* / GPG_SIGNING_* env vars, so the shared release job can't authenticate to Sonatype or sign jars. Reading via findProperty(...) with the existing env vars as a fallback keeps the standalone publish-sonatype.yml workflow working unchanged while letting oss-release drive a release without a wrapper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update Sonatype Nexus URLs in build.gradle.kts * Upgrade Nexus publish plugin to version 2.0.0 --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent aa79965 commit 49495db

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

build.gradle.kts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
2+
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
33
id("org.jetbrains.dokka") version "2.0.0"
44
}
55

@@ -39,11 +39,17 @@ tasks.named("dokkaJavadocCollector").configure {
3939
nexusPublishing {
4040
repositories {
4141
sonatype {
42-
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
43-
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
42+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
43+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
4444

45-
username.set(System.getenv("SONATYPE_USERNAME"))
46-
password.set(System.getenv("SONATYPE_PASSWORD"))
45+
username.set(
46+
(findProperty("mavenCentralUsername") as String?)
47+
?: System.getenv("SONATYPE_USERNAME"),
48+
)
49+
password.set(
50+
(findProperty("mavenCentralPassword") as String?)
51+
?: System.getenv("SONATYPE_PASSWORD"),
52+
)
4753
}
4854
}
4955
}

buildSrc/src/main/kotlin/hubspot.publish.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ configure<PublishingExtension> {
5050
}
5151

5252
signing {
53-
val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null }
54-
val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null }
55-
val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null }
53+
val signingKeyId = (findProperty("signingInMemoryKeyId") as String?)?.ifBlank { null }
54+
?: System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null }
55+
val signingKey = (findProperty("signingInMemoryKey") as String?)?.ifBlank { null }
56+
?: System.getenv("GPG_SIGNING_KEY")?.ifBlank { null }
57+
val signingPassword = (findProperty("signingInMemoryKeyPassword") as String?)?.ifBlank { null }
58+
?: System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null }
5659
if (signingKey != null && signingPassword != null) {
5760
useInMemoryPgpKeys(
5861
signingKeyId,

0 commit comments

Comments
 (0)