-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: [Major] added publishing to mavencentral (#49)
* 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
Showing
10 changed files
with
85 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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") } | ||
|
@@ -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") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
plugins { | ||
id("com.mikhailovskii.kmp.module") | ||
id("maven-publish") | ||
} | ||
|
||
kotlin { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
plugins { | ||
id("com.mikhailovskii.kmp.module") | ||
id("maven-publish") | ||
} | ||
|
||
kotlin { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
plugins { | ||
id("com.mikhailovskii.kmp.module") | ||
id("maven-publish") | ||
} | ||
|
||
kotlin { | ||
|