From 4d4520edaef9b11b5d4be68e5845722d9ca6ab29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joris=20Pelgr=C3=B6m?= Date: Thu, 10 Oct 2024 19:33:44 +0200 Subject: [PATCH] Add publishing to Maven Central on release (#7) --- .github/workflows/rc.yml | 11 +++++++++++ build.gradle | 1 + library/build.gradle | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index 01e02a0..493c455 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -39,3 +39,14 @@ jobs: upload_url: ${{ github.event.release.upload_url }} asset_path: ./app/build/outputs/apk/debug/app-debug.apk asset_name: demo.apk + + - name: Publish to Maven Central + if: github.event.release.draft == 'false' + run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache + env: + IMPROV_LIB_RELEASE: ${{ github.event.release.tag_name }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PGP_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_PGP_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PGP_KEY_PASSWORD }} diff --git a/build.gradle b/build.gradle index 2fe3a69..26e7db3 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ buildscript { plugins { id 'org.jetbrains.kotlin.plugin.compose' version "$kotlin_version" apply false + id 'com.vanniktech.maven.publish' version '0.29.0' apply false } task clean(type: Delete) { diff --git a/library/build.gradle b/library/build.gradle index c9ee9e4..088bdb2 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,6 +1,10 @@ +import com.vanniktech.maven.publish.AndroidSingleVariantLibrary +import com.vanniktech.maven.publish.SonatypeHost + plugins { id 'com.android.library' id 'kotlin-android' + id 'com.vanniktech.maven.publish' } android { @@ -28,4 +32,39 @@ android { kotlinOptions { jvmTarget = '1.8' } +} + +mavenPublishing { + configure(new AndroidSingleVariantLibrary("release", true, true)) + + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + + coordinates("org.openhomefoundation.improv-wifi", "sdk-android", "${System.getenv('IMPROV_LIB_RELEASE')}") + + pom { + name = "Android SDK for Improv Wi-Fi" + description = "Easily detect and connect Improv Wi-Fi devices to the network on Android using BLE" + inceptionYear = "2021" + url = "https://github.com/improv-wifi/sdk-android" + licenses { + license { + name = "Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + distribution = "http://www.apache.org/licenses/LICENSE-2.0.txt" + } + } + developers { + developer { + id = "improv-wifi" + name = "Improv Wi-Fi" + url = "https://github.com/improv-wifi" + } + } + scm { + url = "https://github.com/improv-wifi/sdk-android" + connection = "scm:git:git://github.com/improv-wifi/sdk-android.git" + developerConnection = "scm:git:ssh://git@github.com/improv-wifi/sdk-android.git" + } + } } \ No newline at end of file