Skip to content

Commit 436db69

Browse files
committed
sonatype publishing
1 parent a309b06 commit 436db69

2 files changed

Lines changed: 55 additions & 26 deletions

File tree

.github/workflows/publish-release-from-tag.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,13 @@ jobs:
136136
env:
137137
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138138
- name: Publish to Sonatype
139-
run: |
140-
echo "TODO!"
139+
run: |-
140+
export -- GPG_SIGNING_KEY_ID
141+
printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD"
142+
GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')"
143+
./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache
144+
env:
145+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
146+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
147+
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
148+
GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }}

build.gradle

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
plugins {
22
id 'java-library'
33
id 'maven-publish'
4+
id 'signing'
45
id 'com.diffplug.spotless' version '6.25.0'
56
id 'io.freefair.lombok' version '9.0.0-rc2'
7+
id 'com.vanniktech.maven.publish' version '0.28.0'
68
id 'idea'
79
id 'eclipse'
810
}
@@ -224,32 +226,51 @@ jar {
224226
}
225227
}
226228

227-
publishing {
228-
publications {
229-
maven(MavenPublication) {
230-
from components.java
231-
232-
pom {
233-
name = 'Braintrust Java SDK'
234-
description = 'OpenTelemetry-based Braintrust SDK for Java'
235-
url = 'https://github.com/braintrustdata/braintrust-x-java'
236-
237-
licenses {
238-
license {
239-
name = 'MIT License'
240-
url = 'https://opensource.org/licenses/MIT'
241-
}
242-
}
243-
244-
developers {
245-
developer {
246-
id = 'braintrust'
247-
name = 'Braintrust Team'
248-
email = 'support@braintrust.dev'
249-
}
250-
}
229+
import com.vanniktech.maven.publish.JavadocJar
230+
import com.vanniktech.maven.publish.JavaLibrary
231+
import com.vanniktech.maven.publish.SonatypeHost
232+
233+
ext["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY")
234+
ext["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID")
235+
ext["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD")
236+
237+
mavenPublishing {
238+
signAllPublications()
239+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
240+
241+
coordinates(group.toString(), 'braintrust-sdk-java', version.toString())
242+
configure(
243+
new JavaLibrary(
244+
new JavadocJar.Javadoc(),
245+
true
246+
)
247+
)
248+
249+
pom {
250+
name = 'Braintrust Java SDK'
251+
description = 'Braintrust SDK for logs and evals in Java'
252+
url = 'https://github.com/braintrustdata/braintrust-sdk-java'
253+
254+
licenses {
255+
license {
256+
name = 'MIT License'
257+
url = 'https://opensource.org/licenses/MIT'
251258
}
252259
}
260+
261+
developers {
262+
developer {
263+
id = 'braintrust'
264+
name = 'Braintrust Team'
265+
email = 'info@braintrust.dev'
266+
}
267+
}
268+
269+
scm {
270+
connection = 'scm:git:git://github.com/braintrustdata/braintrust-sdk-java.git'
271+
developerConnection = 'scm:git:git://github.com/braintrustdata/braintrust-sdk-java.git'
272+
url = 'https://github.com/braintrustdata/braintrust-sdk-java'
273+
}
253274
}
254275
}
255276

0 commit comments

Comments
 (0)