Skip to content

Commit 0f77474

Browse files
committed
use vannitech
1 parent bb21ff5 commit 0f77474

3 files changed

Lines changed: 32 additions & 86 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ jobs:
2424
distribution: 'oracle'
2525

2626
- name: Upload to Central Portal
27-
run: ./gradlew publishCentralBundle
27+
run: ./gradlew publishAllPublicationsToMavenCentral
2828
env:
29-
SIGNING_PRIVATE_KEY: ${{ secrets.SIGNING_PRIVATE_KEY }}
30-
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
31-
CENTRAL_PORTAL_USERPASS_BASE64: ${{ secrets.CENTRAL_PORTAL_USERPASS_BASE64 }}
29+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
30+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
31+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
32+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}

‎build.gradle‎

Lines changed: 26 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
id "io.freefair.lombok" version "8.6"
55
id "signing"
66
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
7+
id 'com.vanniktech.maven.publish' version '0.30.0'
78
}
89

910
group 'ai.chalk'
@@ -52,18 +53,6 @@ java {
5253
targetCompatibility = JavaVersion.VERSION_17
5354
}
5455

55-
// Required for OSSRH publishing
56-
task javadocJar(type: Jar) {
57-
archiveClassifier.set('javadoc')
58-
from javadoc.destinationDir
59-
}
60-
61-
// Required for OSSRH publishing
62-
task sourcesJar(type: Jar) {
63-
archiveClassifier.set('sources')
64-
from sourceSets.main.allSource
65-
}
66-
6756
def configurePom = { pom ->
6857
pom.name = 'Chalk Java'
6958
pom.description = 'The Java client for Chalk'
@@ -91,83 +80,39 @@ def configurePom = { pom ->
9180
}
9281
}
9382

94-
task createCentralBundle(type: Zip) {
95-
dependsOn 'publishAllPublicationsToRepoRepository'
83+
import com.vanniktech.maven.publish.SonatypeHost
9684

97-
from(layout.buildDirectory.dir('repo')) {
98-
include '**/*'
99-
}
85+
mavenPublishing {
86+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true)
10087

101-
archiveFileName = "bundle.zip"
102-
destinationDirectory = layout.buildDirectory.dir("central-bundle")
103-
}
88+
signAllPublications()
10489

105-
task publishCentralBundle {
106-
dependsOn 'createCentralBundle'
90+
coordinates(project.group.toString(), project.name, project.version.toString())
10791

108-
doLast {
109-
def bundleFile = layout.buildDirectory.file("central-bundle/bundle.zip").get().asFile
92+
pom {
93+
name = 'Chalk Java'
94+
description = 'The Java client for Chalk'
95+
url = 'https://github.com/chalk-ai/chalk-java'
11096

111-
if (!bundleFile.exists()) {
112-
throw new GradleException("Bundle file not found: ${bundleFile}")
97+
licenses {
98+
license {
99+
name = 'The Apache License, Version 2.0'
100+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
101+
}
113102
}
114103

115-
def auth = System.getenv("CENTRAL_PORTAL_USERPASS_BASE64")
116-
117-
if (!auth) {
118-
throw new GradleException("CENTRAL_PORTAL_USERPASS_BASE64 must be set")
104+
developers {
105+
developer {
106+
id = 'chalk-ai'
107+
name = 'Chalk'
108+
email = 'support@chalk.ai'
109+
}
119110
}
120111

121-
println "Uploading bundle (${bundleFile.length() / 1024 / 1024} MB) to Central Portal..."
122-
123-
def connection = new URL("https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC")
124-
.openConnection() as HttpURLConnection
125-
126-
connection.setRequestMethod("POST")
127-
connection.setRequestProperty("Authorization", "Basic ${auth}")
128-
connection.setRequestProperty("Content-Type", "application/zip")
129-
connection.doOutput = true
130-
131-
bundleFile.withInputStream { input ->
132-
connection.outputStream << input
133-
}
134-
135-
def responseCode = connection.responseCode
136-
println "Response code: ${responseCode}"
137-
138-
if (responseCode >= 200 && responseCode < 300) {
139-
println "✓ Successfully uploaded to Central Portal!"
140-
println connection.inputStream.text
141-
} else {
142-
def error = connection.errorStream?.text ?: "No error details"
143-
throw new GradleException("Upload failed with code ${responseCode}: ${error}")
112+
scm {
113+
connection = 'scm:git:git://github.com/chalk-ai/chalk-java.git'
114+
developerConnection = 'scm:git:ssh://github.com:chalk-ai/chalk-java.git'
115+
url = 'https://github.com/chalk-ai/chalk-java/'
144116
}
145117
}
146-
}
147-
148-
publishing {
149-
publications {
150-
mavenJava(MavenPublication) {
151-
from components.java
152-
153-
artifact sourcesJar
154-
artifact javadocJar
155-
156-
pom.with configurePom
157-
}
158-
}
159-
160-
repositories {
161-
maven {
162-
name = 'repo'
163-
url = layout.buildDirectory.dir('repo')
164-
}
165-
}
166-
}
167-
168-
signing {
169-
def signingKey = System.getenv("SIGNING_PRIVATE_KEY") ?: project.findProperty("signingPrivateKey")
170-
def signingPassword = System.getenv("SIGNING_PASSWORD") ?: project.findProperty("signingPassword")
171-
useInMemoryPgpKeys(signingKey, signingPassword)
172-
sign publishing.publications
173-
}
118+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Wed Aug 30 10:32:23 PDT 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)