Skip to content

Commit 6bc5f62

Browse files
Merge pull request #119 from Contextable/chore/publishScript
Adding support for publishing to Maven.
2 parents c69fad5 + 33c87dc commit 6bc5f62

File tree

8 files changed

+454
-20
lines changed

8 files changed

+454
-20
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Manual Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dry_run:
7+
description: "Run publishToMavenLocal instead of publishing to OSSRH"
8+
type: boolean
9+
default: false
10+
skip_tests:
11+
description: "Skip ./gradlew clean check before publishing"
12+
type: boolean
13+
default: false
14+
force:
15+
description: "Ignore dirty worktree guard"
16+
type: boolean
17+
default: false
18+
gradle_args:
19+
description: "Additional arguments forwarded to Gradle (after the publish task)"
20+
type: string
21+
required: false
22+
default: ""
23+
24+
jobs:
25+
publish:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Set up JDK 17
36+
uses: actions/setup-java@v4
37+
with:
38+
distribution: temurin
39+
java-version: "17"
40+
cache: gradle
41+
42+
- name: Ensure scripts are executable
43+
working-directory: sdks/community/kotlin
44+
run: chmod +x publish.sh library/gradlew
45+
46+
- name: Publish artifacts
47+
working-directory: sdks/community/kotlin
48+
env:
49+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_SIGNING_KEY }}
50+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_SIGNING_PASSWORD }}
51+
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
52+
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
53+
run: |
54+
set -euo pipefail
55+
args=()
56+
if [ "${{ inputs.force }}" = "true" ]; then
57+
args+=("--force")
58+
fi
59+
if [ "${{ inputs.skip_tests }}" = "true" ]; then
60+
args+=("--skip-tests")
61+
fi
62+
if [ "${{ inputs.dry_run }}" = "true" ]; then
63+
args+=("--dry-run")
64+
fi
65+
extra="${{ inputs.gradle_args }}"
66+
if [ -n "$extra" ]; then
67+
args+=("--")
68+
# shellcheck disable=SC2206
69+
args+=($extra)
70+
fi
71+
./publish.sh "${args[@]}"

sdks/community/kotlin/build.gradle.kts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
id("signing")
1010
}
1111

12-
group = "com.agui"
12+
group = "com.contextable"
1313
version = "0.1.0"
1414

1515
repositories {
@@ -158,14 +158,14 @@ android {
158158
}
159159

160160
// Publishing configuration
161-
publishing {
162-
publications {
163-
create<MavenPublication>("maven") {
164-
groupId = project.group.toString()
165-
artifactId = "agui4k"
166-
version = project.version.toString()
167-
168-
pom {
161+
publishing {
162+
publications {
163+
create<MavenPublication>("maven") {
164+
groupId = project.group.toString()
165+
artifactId = "agui4k"
166+
version = project.version.toString()
167+
168+
pom {
169169
name.set("AGUI4K")
170170
description.set("Kotlin Multiplatform implementation of the Agent User Interaction Protocol")
171171
url.set("https://github.com/ag-ui-protocol/ag-ui")
@@ -190,10 +190,20 @@ publishing {
190190
connection.set("scm:git:git://github.com/ag-ui-protocol/ag-ui.git")
191191
developerConnection.set("scm:git:ssh://github.com:ag-ui-protocol/ag-ui.git")
192192
}
193-
}
194-
}
195-
}
196-
}
193+
}
194+
}
195+
}
196+
repositories {
197+
maven {
198+
name = "ossrh-staging-api"
199+
url = uri("https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/")
200+
credentials {
201+
username = (findProperty("ossrhUsername") as String?) ?: System.getenv("OSSRH_USERNAME")
202+
password = (findProperty("ossrhPassword") as String?) ?: System.getenv("OSSRH_PASSWORD")
203+
}
204+
}
205+
}
206+
}
197207

198208
// Signing configuration (for Maven Central)
199209
signing {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
rootProject.name = "chatapp-shared"
2+
3+
pluginManagement {
4+
repositories {
5+
google()
6+
gradlePluginPortal()
7+
mavenCentral()
8+
}
9+
}
10+
11+
dependencyResolutionManagement {
12+
repositories {
13+
google()
14+
mavenCentral()
15+
}
16+
}

sdks/community/kotlin/library/build.gradle.kts

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// Root build script for AG-UI-4K multiplatform library
2-
// All modules are configured individually - see each module's build.gradle.kts
1+
import kotlinx.kover.gradle.plugin.dsl.KoverProjectExtension
2+
import org.gradle.api.publish.PublishingExtension
3+
import org.gradle.api.publish.maven.MavenPublication
4+
import org.gradle.jvm.tasks.Jar
5+
36

47
plugins {
58
kotlin("multiplatform") version "2.2.20" apply false
@@ -18,17 +21,55 @@ allprojects {
1821

1922
// Configure all subprojects with common settings
2023
subprojects {
21-
group = "com.agui"
24+
group = "com.contextable"
2225
version = "0.2.3"
2326

2427
apply(plugin = "org.jetbrains.kotlinx.kover")
28+
extensions.configure<KoverProjectExtension>("kover") {
29+
currentProject {
30+
instrumentation {
31+
disabledForTestTasks.addAll(
32+
"jvmTest",
33+
"testDebugUnitTest",
34+
"testReleaseUnitTest"
35+
)
36+
}
37+
}
38+
}
2539

2640
tasks.withType<Test> {
2741
useJUnitPlatform()
2842
}
29-
43+
3044
// Apply Dokka to all subprojects
3145
apply(plugin = "org.jetbrains.dokka")
46+
47+
plugins.withId("org.jetbrains.dokka") {
48+
afterEvaluate {
49+
val dokkaTask = tasks.findByName("dokkaHtml") ?: tasks.findByName("dokkaGenerate")
50+
51+
if (dokkaTask == null) {
52+
logger.warn("Dokka task not found in project ${project.name}; skipping javadocJar attachment.")
53+
return@afterEvaluate
54+
}
55+
56+
val javadocJar = tasks.register("javadocJar", Jar::class.java) {
57+
dependsOn(dokkaTask)
58+
archiveClassifier.set("javadoc")
59+
from(dokkaTask.outputs.files)
60+
}
61+
62+
extensions.configure(PublishingExtension::class.java) {
63+
publications.withType(MavenPublication::class.java) {
64+
val attachToJvm = name.equals("jvm", ignoreCase = true) ||
65+
artifactId.orEmpty().contains("jvm", ignoreCase = true)
66+
if (attachToJvm) {
67+
artifact(javadocJar)
68+
}
69+
}
70+
}
71+
}
72+
}
3273
}
3374

3475
// Simple Dokka V2 configuration - let it use defaults for navigation

sdks/community/kotlin/library/client/build.gradle.kts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
id("signing")
77
}
88

9-
group = "com.agui"
9+
group = "com.contextable"
1010
version = "0.2.3"
1111

1212
repositories {
@@ -183,6 +183,16 @@ publishing {
183183
}
184184
}
185185
}
186+
repositories {
187+
maven {
188+
name = "ossrh-staging-api"
189+
url = uri("https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/")
190+
credentials {
191+
username = (findProperty("ossrhUsername") as String?) ?: System.getenv("OSSRH_USERNAME")
192+
password = (findProperty("ossrhPassword") as String?) ?: System.getenv("OSSRH_PASSWORD")
193+
}
194+
}
195+
}
186196
}
187197

188198
// Signing configuration

sdks/community/kotlin/library/core/build.gradle.kts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
id("signing")
77
}
88

9-
group = "com.agui"
9+
group = "com.contextable"
1010
version = "0.2.3"
1111

1212
repositories {
@@ -160,6 +160,16 @@ publishing {
160160
}
161161
}
162162
}
163+
repositories {
164+
maven {
165+
name = "ossrh-staging-api"
166+
url = uri("https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/")
167+
credentials {
168+
username = (findProperty("ossrhUsername") as String?) ?: System.getenv("OSSRH_USERNAME")
169+
password = (findProperty("ossrhPassword") as String?) ?: System.getenv("OSSRH_PASSWORD")
170+
}
171+
}
172+
}
163173
}
164174

165175
// Signing configuration

sdks/community/kotlin/library/tools/build.gradle.kts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
id("signing")
77
}
88

9-
group = "com.agui"
9+
group = "com.contextable"
1010
version = "0.2.3"
1111

1212
repositories {
@@ -153,6 +153,16 @@ publishing {
153153
}
154154
}
155155
}
156+
repositories {
157+
maven {
158+
name = "ossrh-staging-api"
159+
url = uri("https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/")
160+
credentials {
161+
username = (findProperty("ossrhUsername") as String?) ?: System.getenv("OSSRH_USERNAME")
162+
password = (findProperty("ossrhPassword") as String?) ?: System.getenv("OSSRH_PASSWORD")
163+
}
164+
}
165+
}
156166
}
157167

158168
// Signing configuration

0 commit comments

Comments
 (0)