Skip to content

Commit 7b800ac

Browse files
authored
chore: Setup maven publishing and update docs (#3)
* Add icon * Update publishing * Update icon
1 parent 41210bf commit 7b800ac

18 files changed

Lines changed: 101 additions & 61 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ concurrency:
1010

1111
permissions:
1212
contents: write
13-
packages: write
1413
pages: write
1514
id-token: write
1615

@@ -102,7 +101,7 @@ jobs:
102101
BUILD_BADGE="[![Build](https://github.com/${REPO}/actions/workflows/deploy.yml/badge.svg)](https://github.com/${REPO}/actions/workflows/deploy.yml)"
103102
COVERAGE_BADGE="[![Coverage](https://img.shields.io/badge/coverage-${COVERAGE}%25-${COLOR})](https://github.com/${REPO}/actions/workflows/deploy.yml)"
104103
VERSION_ESCAPED=$(echo "$VERSION" | sed 's/-/--/g')
105-
MAVEN_BADGE="[![Maven](https://img.shields.io/badge/maven-${VERSION_ESCAPED}-blue)](https://github.com/${REPO}/packages)"
104+
MAVEN_BADGE="[![Maven Central](https://img.shields.io/badge/maven--central-${VERSION_ESCAPED}-blue)](https://central.sonatype.com/artifact/dev.skymansandy/json-cmp)"
106105
107106
BADGE_LINE="${BUILD_BADGE} ${COVERAGE_BADGE} ${MAVEN_BADGE}"
108107
@@ -129,7 +128,7 @@ jobs:
129128
git push
130129
131130
publish:
132-
name: Publish SDK
131+
name: Publish to Maven Central
133132
needs: test-and-coverage
134133
runs-on: macos-latest
135134
steps:
@@ -142,11 +141,13 @@ jobs:
142141

143142
- uses: gradle/actions/setup-gradle@v4
144143

145-
- name: Publish to GitHub Packages
144+
- name: Publish and release to Maven Central
146145
env:
147-
MAVEN_REPO_USERNAME: ${{ github.actor }}
148-
MAVEN_REPO_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
149-
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository
146+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
147+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
148+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
149+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
150+
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
150151

151152
deploy-docs:
152153
name: Deploy Docs

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# JsonCMP
2-
[![Build](https://github.com/skymansandy/jsonCMP/actions/workflows/deploy.yml/badge.svg)](https://github.com/skymansandy/jsonCMP/actions/workflows/deploy.yml) [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/skymansandy/jsonCMP/actions/workflows/deploy.yml) [![Maven](https://img.shields.io/badge/maven-1.0.0--alpha1-blue)](https://github.com/skymansandy/jsonCMP/packages)
32

3+
<p align="center">
4+
<img src="docs/icon.svg" width="128" height="128" alt="JsonCMP Icon"/>
5+
</p>
6+
7+
[![Build](https://github.com/skymansandy/jsonCMP/actions/workflows/deploy.yml/badge.svg)](https://github.com/skymansandy/jsonCMP/actions/workflows/deploy.yml) [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/skymansandy/jsonCMP/actions/workflows/deploy.yml) [![Maven Central](https://img.shields.io/badge/maven--central-1.0.0--alpha1-blue)](https://central.sonatype.com/artifact/dev.skymansandy/json-cmp)
48

59
Kotlin Multiplatform Compose JSON viewer and editor component for Android, iOS, and JVM Desktop.
610

@@ -14,19 +18,14 @@ Kotlin Multiplatform Compose JSON viewer and editor component for Android, iOS,
1418

1519
## Installation
1620

17-
Add the GitHub Packages repository to your `settings.gradle.kts`:
21+
Add `mavenCentral()` to your repositories in `settings.gradle.kts`:
1822

1923
```kotlin
2024
// settings.gradle.kts
2125
dependencyResolutionManagement {
2226
repositories {
23-
maven {
24-
url = uri("https://maven.pkg.github.com/skymansandy/jsonCMP")
25-
credentials {
26-
username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_USERNAME")
27-
password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN")
28-
}
29-
}
27+
mavenCentral()
28+
google()
3029
}
3130
}
3231
```
@@ -36,7 +35,7 @@ Then add the dependency:
3635
```kotlin
3736
// build.gradle.kts
3837
dependencies {
39-
implementation("dev.skymansandy:json-cmp:1.0.0-alpha1")
38+
implementation("dev.skymansandy:json-cmp:<version>")
4039
}
4140
```
4241

androidApp/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<application
55
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
67
android:label="@string/app_name"
78
android:supportsRtl="true"
89
android:theme="@style/Theme.JsonCmpSample">
2.49 KB
Loading
1.7 KB
Loading
3.26 KB
Loading
5.28 KB
Loading
7.14 KB
Loading

build.gradle.kts

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ plugins {
1010
alias(libs.plugins.detekt) apply false
1111
alias(libs.plugins.mokkery) apply false
1212
alias(libs.plugins.kover)
13+
alias(libs.plugins.mavenPublish) apply false
1314
}
1415

1516
dependencies {
@@ -29,28 +30,41 @@ subprojects {
2930
val jsoncmpGroup = findProperty("jsoncmp.group") as String
3031
val jsoncmpVersion = findProperty("jsoncmp.version") as String
3132

32-
group = jsoncmpGroup
33-
version = jsoncmpVersion
34-
35-
apply(plugin = "maven-publish")
33+
apply(plugin = "com.vanniktech.maven.publish")
3634

3735
afterEvaluate {
38-
extensions.findByType<PublishingExtension>()?.apply {
39-
repositories {
40-
maven {
41-
name = "GitHubPackages"
42-
url = uri(
43-
System.getenv("MAVEN_REPO_URL")
44-
?: "https://maven.pkg.github.com/skymansandy/jsonCMP"
45-
)
46-
credentials {
47-
username = System.getenv("MAVEN_REPO_USERNAME")
48-
?: findProperty("gpr.user") as? String ?: ""
49-
password = System.getenv("MAVEN_REPO_PASSWORD")
50-
?: findProperty("gpr.key") as? String ?: ""
51-
}
36+
tasks.withType<Sign>().configureEach {
37+
isEnabled = !gradle.startParameter.taskNames.any { it.contains("MavenLocal", ignoreCase = true) }
38+
}
39+
}
40+
41+
extensions.configure<com.vanniktech.maven.publish.MavenPublishBaseExtension> {
42+
coordinates(jsoncmpGroup, name, jsoncmpVersion)
43+
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
44+
signAllPublications()
45+
46+
pom {
47+
name.set("JsonCMP")
48+
description.set("Kotlin Multiplatform Compose JSON viewer and editor component")
49+
url.set("https://github.com/skymansandy/jsonCMP")
50+
licenses {
51+
license {
52+
name.set("MIT License")
53+
url.set("https://opensource.org/licenses/MIT")
54+
}
55+
}
56+
developers {
57+
developer {
58+
id.set("skymansandy")
59+
name.set("skymansandy")
60+
email.set("iamsandythedev@gmail.com")
5261
}
5362
}
63+
scm {
64+
url.set("https://github.com/skymansandy/jsonCMP")
65+
connection.set("scm:git:git://github.com/skymansandy/jsonCMP.git")
66+
developerConnection.set("scm:git:ssh://github.com/skymansandy/jsonCMP.git")
67+
}
5468
}
5569
}
5670
}

docs/getting-started/installation.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,18 @@
22

33
## Repository Setup
44

5-
JsonCMP is published to GitHub Packages. Add the repository to your `settings.gradle.kts`:
5+
JsonCMP is published to Maven Central. Add `mavenCentral()` to your repositories in `settings.gradle.kts`:
66

77
```kotlin
88
// settings.gradle.kts
99
dependencyResolutionManagement {
1010
repositories {
11-
maven {
12-
url = uri("https://maven.pkg.github.com/skymansandy/jsonCMP")
13-
credentials {
14-
username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_USERNAME")
15-
password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN")
16-
}
17-
}
11+
mavenCentral()
12+
google()
1813
}
1914
}
2015
```
2116

22-
> **Note:** GitHub Packages requires authentication. Add `gpr.user` and `gpr.key` to your
23-
> `~/.gradle/gradle.properties` or set `GITHUB_USERNAME` and `GITHUB_TOKEN` environment variables.
24-
> The token needs the `read:packages` scope.
25-
2617
## Gradle (Kotlin DSL)
2718

2819
Add the dependency to your KMP module:
@@ -34,7 +25,7 @@ Add the dependency to your KMP module:
3425
kotlin {
3526
sourceSets {
3627
commonMain.dependencies {
37-
implementation("dev.skymansandy:json-cmp:1.0.0-alpha2")
28+
implementation("dev.skymansandy:json-cmp:<version>")
3829
}
3930
}
4031
}
@@ -45,7 +36,7 @@ Add the dependency to your KMP module:
4536
```kotlin
4637
// build.gradle.kts
4738
dependencies {
48-
implementation("dev.skymansandy:json-cmp:1.0.0-alpha2")
39+
implementation("dev.skymansandy:json-cmp:<version>")
4940
}
5041
```
5142

0 commit comments

Comments
 (0)