Skip to content

Commit 990b9b9

Browse files
authored
FORGE-985-Maven Publishing Redux (#112)
* First pass at github action * maven publishing trigger for testing * Possible fix for 404 * Change in name not respected * deployments vs. upload * Vaniteck plugin * fix for gradle * version * Potential fix for gradle * Fixes for gradle success!!!
1 parent 01f91a5 commit 990b9b9

File tree

4 files changed

+439
-30
lines changed

4 files changed

+439
-30
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up JDK 21
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '21'
20+
distribution: 'temurin'
21+
cache: 'gradle'
22+
23+
- name: Setup Android SDK
24+
uses: android-actions/setup-android@v3
25+
26+
- name: Extract version from tag
27+
id: version
28+
run: |
29+
VERSION=${GITHUB_REF#refs/tags/v}
30+
echo "version=$VERSION" >> $GITHUB_OUTPUT
31+
echo "Publishing version: $VERSION"
32+
33+
- name: Make gradlew executable
34+
run: chmod +x ./sdks/kotlin/gradlew
35+
36+
- name: Publish to Maven Central
37+
working-directory: ./sdks/kotlin
38+
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
39+
env:
40+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }}
41+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_PASSWORD }}
42+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
43+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }}
44+
VERSION: ${{ steps.version.outputs.version }}
45+
46+
- name: Create deployment summary
47+
run: |
48+
echo "## 🚀 Published to Maven Central" >> $GITHUB_STEP_SUMMARY
49+
echo "" >> $GITHUB_STEP_SUMMARY
50+
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
51+
echo "**Artifact:** com.ditto:dittochat:${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
52+
echo "" >> $GITHUB_STEP_SUMMARY
53+
echo "View at: https://central.sonatype.com/artifact/com.ditto/dittochat/${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY

sdks/kotlin/build.gradle.kts

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import java.util.Base64
2+
import java.util.Properties
3+
14
plugins {
25
alias(libs.plugins.android.library)
36
alias(libs.plugins.kotlin.android)
47
alias(libs.plugins.ksp)
58
alias(libs.plugins.hilt)
69
alias(libs.plugins.compose.compiler)
7-
id("maven-publish")
10+
id("com.vanniktech.maven.publish") version "0.36.0"
811
}
912

1013
android {
@@ -16,6 +19,9 @@ android {
1619

1720
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1821
consumerProguardFiles("consumer-rules.pro")
22+
aarMetadata {
23+
minCompileSdk = 24
24+
}
1925
}
2026

2127
buildTypes {
@@ -37,9 +43,6 @@ android {
3743
kotlin {
3844
jvmToolchain(21)
3945
}
40-
publishing {
41-
singleVariant("release") {}
42-
}
4346
}
4447

4548
dependencies {
@@ -80,37 +83,49 @@ dependencies {
8083
debugImplementation(libs.androidx.ui.tooling)
8184
}
8285

83-
publishing {
84-
publications {
85-
register<MavenPublication>("release") {
86-
groupId = "com.ditto"
87-
artifactId = "dittochat"
88-
version = "1.0.0"
86+
val publishVersion = "1.0.0"
87+
88+
mavenPublishing {
89+
// Configure which Sonatype instance to use
90+
publishToMavenCentral(true)
91+
92+
// Enable GPG signing for all publications
93+
signAllPublications()
94+
95+
// Define Maven coordinates
96+
coordinates("com.ditto", "dittochat", publishVersion)
8997

90-
afterEvaluate {
91-
from(components["release"])
98+
// Configure POM metadata
99+
pom {
100+
name.set("DittoChat")
101+
description.set("A chat library for Ditto applications")
102+
inceptionYear.set("2025")
103+
url.set("https://github.com/getditto/dittochat/")
104+
105+
licenses {
106+
license {
107+
name.set("MIT")
108+
url.set("https://github.com/getditto/DittoChat/blob/main/sdks/swift/LICENSE")
92109
}
110+
}
93111

94-
pom {
95-
name.set("DittoChat")
96-
description.set("A Kotlin Android SDK for Ditto Chat")
97-
url.set("https://github.com/getditto/DittoChat")
98-
99-
developers {
100-
developer {
101-
id.set("bmalumphy")
102-
name.set("Bryan Malumphy")
103-
email.set("bryan.malumphy@ditto.com")
104-
}
105-
}
112+
developers {
113+
developer {
114+
id.set("bryan.malumphy")
115+
name.set("Bryan Malumphy")
116+
email.set("bryan.malumphy@ditto.com")
117+
}
118+
developer {
119+
id.set("erik.everson")
120+
name.set("Erik Everson")
121+
email.set("erik.everson@ditto.com")
106122
}
107123
}
108-
}
109124

110-
repositories {
111-
maven {
112-
name = "DittoChat"
113-
url = uri("${project.buildDir}/dittoChat")
125+
scm {
126+
url.set("https://github.com/getditto/DittoChat/")
127+
connection.set("scm:git:git://github.com/getditto/DittoChat.git")
128+
developerConnection.set("scm:git:ssh://git@github.com/getditto/DittoChat.git")
114129
}
115130
}
116-
}
131+
}

0 commit comments

Comments
 (0)