-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from rafsanjani/publish-maven-central
Publish maven central
- Loading branch information
Showing
11 changed files
with
246 additions
and
49 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Publish to Maven Central | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
env: | ||
GPG_KEY: ${{ secrets.GPG_KEY }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'zulu' | ||
java-version: '17' | ||
- name: Configure GPG Key | ||
run: | | ||
mkdir ~/.gpgkey | ||
echo $GPG_KEY > ~/.gpgkey/secring.gpg.b64 | ||
base64 -d ~/.gpgkey/secring.gpg.b64 > ~/.gpgkey/secring.gpg | ||
- name: Deploy to Sonatype | ||
env: | ||
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | ||
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | ||
|
||
run: | | ||
./gradlew publishToSonatype closeAndReleaseStagingRepository --no-parallel --no-daemon -Psigning.keyId=${{secrets.GPG_KEY_ID}} -Psigning.password=${{secrets.GPG_KEY_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gpgkey/secring.gpg) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
plugins { | ||
id("root.publication") | ||
alias(libs.plugins.android.library) apply false | ||
alias(libs.plugins.android.application) apply false | ||
alias(libs.plugins.kotlin.android) apply false | ||
alias(libs.plugins.detekt) apply false | ||
alias(libs.plugins.kotlin.multiplatform) apply false | ||
alias(libs.plugins.compose.compiler) apply false | ||
alias(libs.plugins.ktlint) | ||
signing | ||
} | ||
|
||
apply { | ||
from("scripts/git-hooks.gradle.kts") | ||
} | ||
|
||
subprojects { | ||
pluginManager.apply("org.jlleitschuh.gradle.ktlint") | ||
} | ||
|
||
ktlint { | ||
version = "1.4.0" | ||
} | ||
|
||
group = "io.github.rafsanjani" |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation("io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin:2.0.0") | ||
} | ||
|
||
gradlePlugin { | ||
val rootPackageName = "com.foreverrafs.datepickertimeline" | ||
|
||
plugins { | ||
register("ModulePublicationConventionPlugin") { | ||
id = "module.publication" | ||
implementationClass = "$rootPackageName.ModulePublication" | ||
} | ||
register("RootPublicationConventionPlugin") { | ||
id = "root.publication" | ||
implementationClass = "$rootPackageName.RootPublication" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
pluginManagement { | ||
repositories { | ||
google() | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
|
||
versionCatalogs { | ||
create("libs") { | ||
from("io.github.rafsanjani:versions:2024.10.27") | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
convention-plugins/src/main/kotlin/com/foreverrafs/datepickertimeline/ModulePublication.kt
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.foreverrafs.datepickertimeline | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.publish.PublicationContainer | ||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.gradle.kotlin.dsl.withType | ||
import org.gradle.plugins.signing.SigningExtension | ||
|
||
class ModulePublication : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
applyPlugins() | ||
|
||
publishing { | ||
// Configure all publications | ||
publications.withType<MavenPublication> { | ||
val mavenPublication = this as? MavenPublication | ||
|
||
mavenPublication?.artifactId = | ||
"datepickertimeline${ | ||
"-$name".takeUnless { "kotlinMultiplatform" in name }.orEmpty() | ||
}".removeSuffix("Release") | ||
|
||
pom { | ||
name.set("Date Picker Timeline") | ||
description.set("A linear date picker for jetpack compose multiplatform") | ||
url.set("https://github.com/rafsanjani/datepickertimeline") | ||
|
||
licenses { | ||
license { | ||
name.set("MIT") | ||
url.set("https://opensource.org/licenses/mit") | ||
} | ||
} | ||
issueManagement { | ||
system.set("Github") | ||
url.set("https://github.com/rafsanjani/datepickertimeline/issues") | ||
} | ||
scm { | ||
connection.set("https://github.com/rafsanjani/datepickertimeline.git") | ||
url.set("https://github.com/rafsanjani/datepickertimeline.git") | ||
} | ||
developers { | ||
developer { | ||
id.set("RafsanjaniAziz") | ||
name.set("Rafsanjani Abdul-Aziz") | ||
email.set("[email protected]") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
sign(publications) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun Project.applyPlugins() { | ||
pluginManager.apply("signing") | ||
pluginManager.apply("maven-publish") | ||
} | ||
|
||
private fun Project.signing(action: SigningExtension.() -> Unit) = extensions.configure(action) | ||
private fun Project.publishing(action: PublishingExtension.() -> Unit) = extensions.configure(action) | ||
|
||
private val SigningExtension.publications: PublicationContainer | ||
get() = project.extensions.getByType<PublishingExtension>().publications |
33 changes: 33 additions & 0 deletions
33
convention-plugins/src/main/kotlin/com/foreverrafs/datepickertimeline/RootPublication.kt
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.foreverrafs.datepickertimeline | ||
|
||
import io.github.gradlenexus.publishplugin.NexusPublishExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
class RootPublication : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply("io.github.gradle-nexus.publish-plugin") | ||
|
||
nexusPublishing { | ||
repositories { | ||
sonatype { | ||
val stagingProfileID = System.getenv("OSSRH_STAGING_PROFILE_ID") | ||
val mavenCentralUsername = System.getenv("MAVEN_CENTRAL_USERNAME") | ||
val mavenCentralPassword = System.getenv("MAVEN_CENTRAL_PASSWORD") | ||
|
||
useStaging.set(true) | ||
|
||
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) | ||
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) | ||
username.set(mavenCentralUsername) | ||
password.set(mavenCentralPassword) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun Project.nexusPublishing(action: NexusPublishExtension.() -> Unit) = extensions.configure(action) |
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 was deleted.
Oops, something went wrong.
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