Skip to content

Commit

Permalink
feature: [Major] added publishing to mavencentral (#49)
Browse files Browse the repository at this point in the history
* Added publishing to mavencentral

* Test with snapshot host

* Readme update

---------

Co-authored-by: sergei-mikhailovskii-idf <[email protected]>
  • Loading branch information
1 parent 12746df commit 288ee5f
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 52 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/publish-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ jobs:
build_project:
runs-on: macos-latest
env:
GITHUB_USER: ${{ secrets.USER }}
GITHUB_API_KEY: ${{ secrets.PAT }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{secrets.SONATYPE_NEXUS_USERNAME}}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.SONATYPE_NEXUS_PASSWORD}}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.SIGNING_SECRET_KEY_RING}}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{secrets.SIGNING_KEY_ID}}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.SIGNING_PASSWORD}}
steps:
- name: Checkout
uses: actions/[email protected]
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ jobs:
build_project:
runs-on: macos-latest
env:
GITHUB_USER: ${{ secrets.USER }}
GITHUB_API_KEY: ${{ secrets.PAT }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{secrets.SONATYPE_NEXUS_USERNAME}}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.SONATYPE_NEXUS_PASSWORD}}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.SIGNING_SECRET_KEY_RING}}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{secrets.SIGNING_KEY_ID}}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.SIGNING_PASSWORD}}
steps:
- name: Checkout
uses: actions/[email protected]
Expand Down
58 changes: 35 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,14 @@ Library that allows to launch in app (or in market) review from the KMP shared c
Android and iOS

## How to integrate?
1) Add the repository in settings.gradle.kts:
1) Add the dependency you need into `commonMain`:
```kotlin
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/SergeiMikhailovskii/kmp-app-review")
credentials {
username = System.getenv("GITHUB_USER")
password = System.getenv("GITHUB_API_KEY")
}
}
}
}
```
2) Add the dependency you need into `commonMain`:
```kotlin
implementation("com.mikhailovskii.kmp:in-app-review-kmp:$latest_tag") // Amazon, App Gallery, Galaxy Store
implementation("com.mikhailovskii.kmp:in-app-review-kmp-google-play:$latest_tag") // Google Play + Amazon, App Gallery, Galaxy Store
implementation("com.mikhailovskii.kmp:in-app-review-kmp-rustore:$latest_tag") // RuStore + Amazon, App Gallery, Galaxy Store
implementation("io.github.sergeimikhailovskii:in-app-review-kmp:$latest_tag") // Amazon, App Gallery, Galaxy Store
implementation("io.github.sergeimikhailovskii:in-app-review-kmp-google-play:$latest_tag") // Google Play + Amazon, App Gallery, Galaxy Store
implementation("io.github.sergeimikhailovskii:in-app-review-kmp-rustore:$latest_tag") // RuStore + Amazon, App Gallery, Galaxy Store
```

3) Create an instance of class that implements `InAppReviewDelegate` interface.
2) Create an instance of class that implements `InAppReviewDelegate` interface.
Now library supports 3 implementations (depends on the market u need):
- `AmazonInAppReviewManager`
- `AppGalleryInAppReviewManager`
Expand All @@ -42,7 +26,7 @@ implementation("com.mikhailovskii.kmp:in-app-review-kmp-rustore:$latest_tag") //
- `GooglePlayInAppReviewManager`
- `RuStoreInAppReviewManager`

4) To launch in-app review call
3) To launch in-app review call
```kotlin
fun requestInAppReview(): Flow<ReviewCode>
```
Expand All @@ -56,7 +40,7 @@ implementation("com.mikhailovskii.kmp:in-app-review-kmp-rustore:$latest_tag") //
- For Google Play used [in-app-review api](https://developer.android.com/guide/playcore/in-app-review)
- For RuStore used [in-app-review-api](https://www.rustore.ru/help/sdk/reviews-ratings/kotlin-java/2-0-0)

5) To launch in-market review call
4) To launch in-market review call
```kotlin
fun requestInMarketReview(): Flow<ReviewCode>
```
Expand All @@ -71,6 +55,34 @@ this method registers activity result listener so u should invoke it before the
### Note 2
RuStore's impl has minSdk=26, other dependencies have minSdk=21

## Breaking changes in the version 3.0
1) Since new artifacts versions are published to the MavenCentral instead of Github Maven, the `group id` was changed:
```diff
dependencies {
+ implementation("io.github.sergeimikhailovskii:in-app-review-kmp:$latest_tag") // Amazon, App Gallery, Galaxy Store
- implementation("com.mikhailovskii.kmp:in-app-review-kmp:$latest_tag") // Amazon, App Gallery, Galaxy Store
+ implementation("io.github.sergeimikhailovskii:in-app-review-kmp-google-play:$latest_tag") // Google Play + Amazon, App Gallery, Galaxy Store
- implementation("com.mikhailovskii.kmp:in-app-review-kmp-google-play:$latest_tag") // Google Play + Amazon, App Gallery, Galaxy Store
+ implementation("io.github.sergeimikhailovskii:in-app-review-kmp-rustore:$latest_tag")
- implementation("com.mikhailovskii.kmp:in-app-review-kmp-rustore:$latest_tag") // RuStore + Amazon, App Gallery, Galaxy Store
}
```
2) Separate repository can be deleted
```diff
dependencyResolutionManagement {
repositories {
+ mavenCentral()
- maven {
- url = uri("https://maven.pkg.github.com/SergeiMikhailovskii/kmp-app-review")
- credentials {
- username = System.getenv("GITHUB_USER")
- password = System.getenv("GITHUB_API_KEY")
- }
- }
}
}
```

## Breaking changes in the version 2.0

1) Google Play's implementation was moved from the in-app-review-kmp module to the in-app-review-kmp-google-play module.
Expand Down
1 change: 1 addition & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ gradlePlugin {
dependencies {
compileOnly(libs.android.gradle)
compileOnly(libs.kotlin.gradle.plugin)
compileOnly(libs.maven.publish.plugin)
}
57 changes: 35 additions & 22 deletions build-logic/convention/src/main/kotlin/KMPModuleConventionPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import com.android.build.gradle.LibraryExtension
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.api.DefaultTask
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
Expand All @@ -16,9 +18,9 @@ private class KMPModuleConventionPlugin : Plugin<Project> {
with(pluginManager) {
apply(extensions.getPluginId("androidLibrary"))
apply(extensions.getPluginId("kotlinMultiplatform"))
apply("maven-publish")
apply(extensions.getPluginId("mavenPublish"))
}
group = "com.mikhailovskii.kmp"
group = "io.github.sergeimikhailovskii"
version = System.getenv("LIBRARY_VERSION") ?: extensions.getVersion("pluginVersion")
extensions.configure<KotlinMultiplatformExtension> {
androidTarget { publishLibraryVariants("release", "debug") }
Expand All @@ -40,29 +42,40 @@ private class KMPModuleConventionPlugin : Plugin<Project> {
}
}
extensions.configure<PublishingExtension> {
publications {
matching {
return@matching it.name in listOf(
"iosArm64",
"iosX64",
"kotlinMultiplatform"
)
}.all {
tasks.withType<AbstractPublishToMaven>()
.matching { it.publication == this@all }
.configureEach { onlyIf { findProperty("isMainHost") == "true" } }
}
}
repositories {
maven {
url = uri("https://maven.pkg.github.com/SergeiMikhailovskii/kmp-app-review")
credentials {
username = System.getenv("GITHUB_USER")
password = System.getenv("GITHUB_API_KEY")
publications.withType<MavenPublication> {
pom {
name.set("kmp-in-app-review")
description.set("Library that allows to launch in app (or in market) review from the KMP shared code")
url.set("https://github.com/SergeiMikhailovskii/kmp-app-review")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

developers {
developer {
id.set("SergeiMikhailovskii")
name.set("Sergei Mikhailovskii")
email.set("[email protected]")
}
}

scm {
url.set("https://github.com/SergeiMikhailovskii/kmp-app-review")
connection.set("scm:git:git://github.com/SergeiMikhailovskii/kmp-app-review.git")
developerConnection.set("scm:git:git://github.com/SergeiMikhailovskii/kmp-app-review.git")
}
}
}
}
extensions.configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
}
tasks.register("buildAndPublish", DefaultTask::class) {
dependsOn("build")
dependsOn("publish")
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.kotlinMultiplatform).apply(false)
alias(libs.plugins.kotlinCocoapods).apply(false)
alias(libs.plugins.mavenPublish).apply(false)
}

tasks.register("buildAndPublish", DefaultTask::class) {
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ androidx-fragment = "1.6.2"
rustore-review = "2.0.0"
reviewKtx = "2.0.1"
coroutines = "1.8.0"
mavenPublish = "0.28.0"

[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
Expand All @@ -26,10 +27,12 @@ coroutines-play-services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-

android-gradle = { module = "com.android.tools.build:gradle", version.ref = "agp" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "mavenPublish" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }
1 change: 0 additions & 1 deletion in-app-review-kmp-google-play/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.mikhailovskii.kmp.module")
id("maven-publish")
}

kotlin {
Expand Down
1 change: 0 additions & 1 deletion in-app-review-kmp-rustore/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.mikhailovskii.kmp.module")
id("maven-publish")
}

kotlin {
Expand Down
1 change: 0 additions & 1 deletion in-app-review-kmp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.mikhailovskii.kmp.module")
id("maven-publish")
}

kotlin {
Expand Down

0 comments on commit 288ee5f

Please sign in to comment.