Skip to content

Commit bc53c47

Browse files
committed
setup multiplatform publishing
1 parent 4402ce0 commit bc53c47

File tree

6 files changed

+139
-115
lines changed

6 files changed

+139
-115
lines changed

.github/workflows/publish.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
release:
11+
name: Create GitHub Release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v4
16+
17+
- name: Create GitHub Release
18+
uses: softprops/action-gh-release@v1
19+
with:
20+
generate_release_notes: true
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
23+
24+
publish:
25+
name: Release build and publish
26+
runs-on: macOS-latest
27+
needs: release
28+
steps:
29+
- name: Check out code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up JDK 21
33+
uses: actions/setup-java@v4
34+
with:
35+
distribution: 'zulu'
36+
java-version: 21
37+
38+
- name: Publish to MavenCentral
39+
run: ./gradlew :chitralekhan:publishToMavenCentral --no-configuration-cache
40+
env:
41+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
42+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
43+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
44+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
45+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}

build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ plugins {
99
alias(libs.plugins.androidKotlinMultiplatformLibrary) apply false
1010
alias(libs.plugins.androidLint) apply false
1111
alias(libs.plugins.kotlinxSerialization) apply false
12-
alias(libs.plugins.maven.publish) apply false
13-
id("maven-publish")
1412
}
1513

chitralekhan/build.gradle.kts

Lines changed: 44 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import com.vanniktech.maven.publish.SonatypeHost
12
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
23

34
plugins {
@@ -8,7 +9,7 @@ plugins {
89
alias(libs.plugins.composeCompiler)
910
alias(libs.plugins.composeHotReload)
1011
id("maven-publish")
11-
alias(libs.plugins.maven.publish)
12+
id("com.vanniktech.maven.publish") version "0.30.0"
1213
}
1314

1415
kotlin {
@@ -42,7 +43,7 @@ kotlin {
4243
iosSimulatorArm64()
4344
).forEach { iosTarget ->
4445
iosTarget.binaries.framework {
45-
baseName = "ChitralekhanKit"
46+
baseName = "chitralekhanKit"
4647
}
4748
}
4849

@@ -79,110 +80,44 @@ compose.resources {
7980
}
8081

8182

82-
//
83-
//android {
84-
// namespace = "com.daiatech.chitralekhan"
85-
// compileSdk = 35
86-
//
87-
// defaultConfig {
88-
// minSdk = 21
89-
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
90-
// consumerProguardFiles("consumer-rules.pro")
91-
// }
92-
//
93-
// buildTypes {
94-
// release {
95-
// isMinifyEnabled = false
96-
// proguardFiles(
97-
// getDefaultProguardFile("proguard-android-optimize.txt"),
98-
// "proguard-rules.pro"
99-
// )
100-
// }
101-
// }
102-
// compileOptions {
103-
// sourceCompatibility = JavaVersion.VERSION_17
104-
// targetCompatibility = JavaVersion.VERSION_17
105-
// }
106-
//
107-
// kotlinOptions.jvmTarget = "17"
108-
// buildFeatures.compose = true
109-
//
110-
// publishing {
111-
// singleVariant("release") {
112-
// withSourcesJar()
113-
// }
114-
// }
115-
//}
116-
//
117-
//dependencies {
118-
//
119-
// implementation(libs.androidx.core.ktx)
120-
// implementation(libs.androidx.lifecycle.runtime.ktx)
121-
// implementation(libs.androidx.activity.compose)
122-
// implementation(libs.androidx.appcompat)
123-
//
124-
// implementation(platform(libs.androidx.compose.bom))
125-
// implementation(libs.androidx.ui)
126-
// implementation(libs.androidx.ui.graphics)
127-
// implementation(libs.androidx.ui.tooling.preview)
128-
// implementation(libs.androidx.material3)
129-
// debugImplementation(libs.androidx.ui.tooling)
130-
//
131-
// implementation(libs.kotlinx.serialization.json)
132-
//}
133-
//
134-
//// Publishing tasks
135-
//val publishGroupId = "io.github.karya-inc"
136-
//val publishArtifactVersion = "0.0.4"
137-
//val publishArtifactId = "chitralekhan"
138-
//
139-
//group = publishGroupId
140-
//version = version
141-
//
142-
//publishing {
143-
// publications {
144-
// create<MavenPublication>("release") {
145-
// groupId = publishGroupId
146-
// artifactId = publishArtifactId
147-
// version = publishArtifactVersion
148-
//
149-
// afterEvaluate { from(components["release"]) }
150-
//
151-
// pom {
152-
// name.set(publishArtifactId)
153-
// description.set("An Android library for image annotationo")
154-
// url.set("https://github.com/karya-inc/ChitraLekhan.git")
155-
//
156-
// licenses {
157-
// license {
158-
// name.set("GNU license")
159-
// url.set("https://opensource.org/license/gpl-3-0")
160-
// }
161-
// }
162-
//
163-
// developers {
164-
// developer {
165-
// id.set("divyansh@karya.in")
166-
// name.set("Divyansh Kushwaha")
167-
// email.set("divyansh@karya.in")
168-
// }
169-
// }
170-
//
171-
// scm {
172-
// connection.set("scm:git:ssh://git@github.com/karya-inc/ChitraLekhan.git")
173-
// developerConnection.set("scm:git:ssh://git@github.com/karya-inc/ChitraLekhan.git")
174-
// url.set("https://github.com/karya-inc/ChitraLekhan.git")
175-
// }
176-
// }
177-
// }
178-
// }
179-
//}
180-
//
181-
//signing {
182-
// useInMemoryPgpKeys(
183-
// rootProject.ext["signing.keyId"] as String,
184-
// rootProject.ext["signing.key"] as String,
185-
// rootProject.ext["signing.password"] as String
186-
// )
187-
// sign(publishing.publications)
188-
//}
83+
group = "io.github.karya-inc"
84+
version = "0.0.4"
85+
86+
mavenPublishing {
87+
val artifactId = "chitralekhan"
88+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
89+
signAllPublications()
90+
91+
coordinates(
92+
groupId = group.toString(),
93+
artifactId = artifactId,
94+
version = version.toString()
95+
)
96+
97+
pom {
98+
name.set(artifactId)
99+
description.set("An Android library for image annotation")
100+
url.set("https://github.com/karya-inc/ChitraLekhan.git")
101+
102+
licenses {
103+
license {
104+
name.set("GNU license")
105+
url.set("https://opensource.org/license/gpl-3-0")
106+
}
107+
}
108+
109+
developers {
110+
developer {
111+
id.set("divyansh@karya.in")
112+
name.set("Divyansh Kushwaha")
113+
email.set("divyansh@karya.in")
114+
}
115+
}
116+
117+
scm {
118+
connection.set("scm:git:ssh://git@github.com/karya-inc/ChitraLekhan.git")
119+
developerConnection.set("scm:git:ssh://git@github.com/karya-inc/ChitraLekhan.git")
120+
url.set("https://github.com/karya-inc/ChitraLekhan.git")
121+
}
122+
}
123+
}

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ kotlinx-coroutines = "1.10.2"
1818
kotlinStdlib = "2.2.10"
1919
runner = "1.5.2"
2020
core = "1.5.0"
21-
mavenPublish = "0.30.0"
2221

2322
[libraries]
2423
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
@@ -47,4 +46,3 @@ kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref =
4746
kotlinxSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
4847
androidKotlinMultiplatformLibrary = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }
4948
androidLint = { id = "com.android.lint", version.ref = "agp" }
50-
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }

release.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if ! git diff --quiet || ! git diff --cached --quiet; then
6+
echo "Uncommitted changes detected. Please commit or stash them before running this script."
7+
exit 1
8+
fi
9+
10+
current_branch=$(git rev-parse --abbrev-ref HEAD)
11+
echo "Current branch: $current_branch"
12+
13+
git checkout main
14+
git pull origin main
15+
16+
current_version=$(sed -En 's/.*version = "([0-9]+\.[0-9]+\.[0-9]+)"/\1/p' chitralekhan/build.gradle.kts)
17+
echo "Current version: $current_version"
18+
19+
IFS='.' read -r major minor patch <<< "$current_version"
20+
21+
if (( patch < 9 )); then
22+
patch=$((patch + 1))
23+
else
24+
patch=0
25+
if (( minor < 9 )); then
26+
minor=$((minor + 1))
27+
else
28+
minor=0
29+
major=$((major + 1))
30+
fi
31+
fi
32+
33+
new_version="${major}.${minor}.${patch}"
34+
echo "New version: $new_version"
35+
36+
sed -i.bak "s/version = \"$current_version\"/version = \"$new_version\"/g" chitralekhan/build.gradle.kts
37+
rm chitralekhan/build.gradle.kts.bak
38+
39+
git add chitralekhan/build.gradle.kts
40+
git commit -m "release: bump up version"
41+
42+
git tag "v$new_version"
43+
44+
git push -u origin main
45+
git push origin "v$new_version"
46+
47+
echo "Version bumped to $new_version and pushed with tag v$new_version"
48+
49+
git checkout "$current_branch"

settings.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
rootProject.name = "ChitraLekhan"
2-
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
1+
rootProject.name = "chitralekhan"
32

43
pluginManagement {
54
repositories {

0 commit comments

Comments
 (0)