Skip to content

Commit

Permalink
chore: publish to maven central portal (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 26, 2024
1 parent 35b7ae5 commit 2fcca5a
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-sonatype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
export -- GPG_SIGNING_KEY_ID
printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD"
GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')"
./gradlew --parallel --no-daemon publish
./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD"
env:
SONATYPE_USERNAME: ${{ secrets.LITHIC_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.LITHIC_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}
Expand Down
12 changes: 1 addition & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
plugins {
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"

}

allprojects {
group = "com.lithic.api"
version = "0.71.0" // x-release-please-version
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))

username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}
4 changes: 4 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "1.9.22"
id("com.vanniktech.maven.publish") version "0.28.0"
}

repositories {
gradlePluginPortal()
mavenCentral()
}

dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0")
}
14 changes: 4 additions & 10 deletions buildSrc/src/main/kotlin/lithic.java.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import java.util.Locale
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost

plugins {
`java-library`
Expand All @@ -11,11 +14,6 @@ repositories {
mavenCentral()
}

configure<JavaPluginExtension> {
withJavadocJar()
withSourcesJar()
}

configure<SpotlessExtension> {
java {
importOrder()
Expand All @@ -36,10 +34,6 @@ tasks.withType<JavaCompile>().configureEach {
options.release.set(8)
}

tasks.named<Jar>("javadocJar") {
setZip64(true)
}

tasks.named<Jar>("jar") {
manifest {
attributes(mapOf(
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/lithic.kotlin.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.vanniktech.maven.publish.*

plugins {
id("lithic.java")
Expand Down
83 changes: 35 additions & 48 deletions buildSrc/src/main/kotlin/lithic.publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,52 @@ import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.get
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost

plugins {
`maven-publish`
`signing`
id("com.vanniktech.maven.publish")
}

configure<PublishingExtension> {
publications {
register<MavenPublication>("maven") {
from(components["java"])
repositories {
gradlePluginPortal()
mavenCentral()
}

pom {
name.set("Lithic Developer API")
description.set("The Lithic Developer API is designed to provide a predictable programmatic\ninterface for accessing your Lithic account through an API and transaction\nwebhooks. Note that your API key is a secret and should be treated as such.\nDon't share it with anyone, including us. We will never ask you for it.")
url.set("https://docs.lithic.com")
extra["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY")
extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID")
extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD")

licenses {
license {
name.set("Apache-2.0")
}
}
configure<MavenPublishBaseExtension> {
signAllPublications()
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

developers {
developer {
name.set("Lithic")
email.set("sdk-feedback@lithic.com")
}
}
this.coordinates(project.group.toString(), project.name, project.version.toString())

scm {
connection.set("scm:git:git://github.com/lithic-com/lithic-java.git")
developerConnection.set("scm:git:git://github.com/lithic-com/lithic-java.git")
url.set("https://github.com/lithic-com/lithic-java")
}
pom {
name.set("Lithic Developer API")
description.set("The Lithic Developer API is designed to provide a predictable programmatic\ninterface for accessing your Lithic account through an API and transaction\nwebhooks. Note that your API key is a secret and should be treated as such.\nDon't share it with anyone, including us. We will never ask you for it.")
url.set("https://docs.lithic.com")

versionMapping {
allVariants {
fromResolutionResult()
}
}
licenses {
license {
name.set("Apache-2.0")
}
}
}
}

signing {
val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null }
val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null }
val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null }
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(
signingKeyId,
signingKey,
signingPassword,
)
sign(publishing.publications["maven"])
}
}
developers {
developer {
name.set("Lithic")
email.set("sdk-feedback@lithic.com")
}
}

tasks.named("publish") {
dependsOn(":closeAndReleaseSonatypeStagingRepository")
scm {
connection.set("scm:git:git://github.com/lithic-com/lithic-java.git")
developerConnection.set("scm:git:git://github.com/lithic-com/lithic-java.git")
url.set("https://github.com/lithic-com/lithic-java")
}
}
}

0 comments on commit 2fcca5a

Please sign in to comment.