From 1baf351ffd52a9c695a3ad7a92a66c7cdb2e8793 Mon Sep 17 00:00:00 2001 From: Afsal Date: Mon, 29 Jun 2026 14:45:44 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20maven=20central=20publi?= =?UTF-8?q?sh=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 35 ++++++++++++++++++++++++ README.md | 16 ++++++++++- build.gradle.kts | 1 + dotlottie/build.gradle.kts | 50 ++++++++++++++++++++++++++--------- gradle/libs.versions.toml | 2 ++ 5 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0fcd54c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Publish to Maven Central + +# Publishes the :dotlottie library to the Maven Central Portal. +# Triggered when a GitHub Release is published, or manually. + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "17" + + - name: Set up Android SDK + uses: android-actions/setup-android@v3 + + - name: Install NDK and CMake + run: sdkmanager "ndk;29.0.14206865" "cmake;3.22.1" + + - name: Publish to Maven Central + run: ./gradlew :dotlottie:publishToMavenCentral --no-daemon --stacktrace + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} diff --git a/README.md b/README.md index 80fa099..4ddaf6c 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,21 @@ You can find and run the sample application in the `sample` directory. ## Installation -To add DotLottie Android, you need to add this dependency to your module's gradle file: +### Maven Central (recommended) + +```kotlin +repositories { + mavenCentral() +} +``` + +```kotlin +dependencies { + implementation("com.lottiefiles:dotlottie-android:0.5.0") +} +``` + +### JitPack ```kotlin repositories { diff --git a/build.gradle.kts b/build.gradle.kts index 2c01ffd..493c1a7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,7 @@ plugins { alias(libs.plugins.kotlinAndroid) apply false alias(libs.plugins.androidLibrary) apply false // id("com.google.devtools.ksp") version "1.9.22-1.0.16" apply false + alias(libs.plugins.mavenPublish) apply false id("maven-publish") } true // Needed to make the Suppress annotation work for the plugins block diff --git a/dotlottie/build.gradle.kts b/dotlottie/build.gradle.kts index ea726e5..4d92faf 100644 --- a/dotlottie/build.gradle.kts +++ b/dotlottie/build.gradle.kts @@ -1,7 +1,9 @@ +import com.vanniktech.maven.publish.SonatypeHost + plugins { id("com.android.library") id("org.jetbrains.kotlin.android") - `maven-publish` + id("com.vanniktech.maven.publish") id("com.lottiefiles.dotlottie-rust") } @@ -36,7 +38,7 @@ dotlottieRust { // apiLevel = 21 } -group = "com.github.LottieFiles" +group = "com.lottiefiles" version = "0.14.2" android { @@ -114,19 +116,43 @@ android { } } -publishing { - publications { - register("release") { - groupId = "com.github.LottieFiles" - artifactId = "dotlottie-android" - version = version - afterEvaluate { - from(components["release"]) +mavenPublishing { + coordinates("com.lottiefiles", "dotlottie-android", version.toString()) + + pom { + name.set("dotLottie Android") + description.set( + "A powerful Android library for rendering Lottie and dotLottie animations " + + "with advanced features like interactivity, theming, and state machines." + ) + inceptionYear.set("2024") + url.set("https://github.com/LottieFiles/dotlottie-android") + licenses { + license { + name.set("MIT License") + url.set("https://github.com/LottieFiles/dotlottie-android/blob/main/LICENSE") + distribution.set("repo") + } + } + developers { + developer { + id.set("lottiefiles") + name.set("LottieFiles") + url.set("https://lottiefiles.com") } } + scm { + url.set("https://github.com/LottieFiles/dotlottie-android") + connection.set("scm:git:git://github.com/LottieFiles/dotlottie-android.git") + developerConnection.set("scm:git:ssh://git@github.com/LottieFiles/dotlottie-android.git") + } } - repositories { - mavenLocal() + + val hasSigningKey = providers.gradleProperty("signingInMemoryKey").isPresent || + providers.environmentVariable("ORG_GRADLE_PROJECT_signingInMemoryKey").isPresent + if (hasSigningKey) { + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = false) + signAllPublications() } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f966721..74de9f2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,6 +18,7 @@ material = "1.9.0" moshi = "1.15.0" moshi-kotlin-codegen = "1.12.0" okhttp = "4.12.0" +maven-publish = "0.30.0" ui = "1.6.0" ui-test-junit4 = "1.6.0" ui-tooling-preview = "1.6.0" @@ -55,4 +56,5 @@ material = { group = "com.google.android.material", name = "material", version.r androidApplication = { id = "com.android.application", version.ref = "agp" } kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } androidLibrary = { id = "com.android.library", version.ref = "agp" } +mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" }