From 9bfdfce2b32a9c97ca8ff947c3bf39354e1c79c5 Mon Sep 17 00:00:00 2001 From: ankitkumar Date: Fri, 26 Jan 2024 03:12:57 +0530 Subject: [PATCH 1/4] used gradle nexus plugin --- app/build.gradle | 2 +- build.gradle | 11 ++++ gradle/publish-package.gradle | 110 +++++++++------------------------- 3 files changed, 41 insertions(+), 82 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2e31741..d50134d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,7 +52,7 @@ dependencies { implementation('org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0') } - implementation 'io.github.pseudoankit:coachmark:1.0.2' + implementation 'io.github.pseudoankit:coachmark:1.0.3' implementation 'androidx.activity:activity-compose:1.7.2' implementation platform('androidx.compose:compose-bom:2022.10.00') implementation 'androidx.compose.ui:ui' diff --git a/build.gradle b/build.gradle index 24d2b3a..96ea28c 100644 --- a/build.gradle +++ b/build.gradle @@ -8,4 +8,15 @@ plugins { id 'com.android.application' version '8.0.1' apply false id 'com.android.library' version '8.0.1' apply false id 'org.jetbrains.kotlin.android' version '1.7.20' apply false + id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' } + +nexusPublishing { + repositories { + sonatype { + username = System.getenv("OSS_USERNAME") + password = System.getenv("OSS_PASSWORD") + stagingProfileId = System.getenv("OSS_STAGING_PROFILE_ID") + } + } +} \ No newline at end of file diff --git a/gradle/publish-package.gradle b/gradle/publish-package.gradle index 4098845..7b32cd7 100644 --- a/gradle/publish-package.gradle +++ b/gradle/publish-package.gradle @@ -3,36 +3,46 @@ apply plugin: 'signing' ext { GROUP_ID = "io.github.pseudoankit" - VERSION_NAME = "1.0.3" + VERSION = "1.0.3" - POM_DESCRIPTION = "Compose library to add coachmark" - POM_URL = "https://github.com/pseudoankit/coachmark" - POM_SCM_CONNECTION = "scm:git@github.com:pseudoankit/coachmark.git" - - OSS_USERNAME = System.getenv("OSS_USERNAME") - OSS_PASSWORD = System.getenv("OSS_PASSWORD") + SITE_URL = 'https://github.com/pseudoankit/coachmark' + GIT_URL = 'https://github.com/pseudoankit/coachmark.git' + POM_DESCRIPTION = "Compose library to add coachmark" + POM_URL = SITE_URL } signing { useInMemoryPgpKeys( - System.getenv("SIGNING_KEY_ID"), - System.getenv("SIGNING_KEY"), - System.getenv("SIGNING_PASSWORD"), + System.getenv("OSS_SIGNING_KEY_ID"), + System.getenv("OSS_SIGNING_KEY"), + System.getenv("OSS_SIGNING_PASSWORD"), ) sign publishing.publications } +// If you want to publish your sources as well +task androidSourcesJar(type: Jar) { + archiveClassifier.set('sources') + from android.sourceSets.main.java.srcDirs + from android.sourceSets.main.kotlin.srcDirs +} + +artifacts { + archives androidSourcesJar +} + afterEvaluate { publishing { publications { release(MavenPublication) { - from components.release - groupId GROUP_ID artifactId ARTIFACT_ID - version VERSION_NAME + version VERSION + + from components.release + artifact androidSourcesJar pom { name = ARTIFACT_ID @@ -44,11 +54,7 @@ afterEvaluate { url = "https://www.apache.org/licenses/LICENSE-2.0.txt" } } - scm { - connection = POM_SCM_CONNECTION - developerConnection = POM_SCM_CONNECTION - url = POM_URL - } + developers { developer { id = 'pseudoankit' @@ -56,73 +62,15 @@ afterEvaluate { email = 'lostankit7@gmail.com' } } - } - } - } - repositories { - maven { - name = "SonatypeSnapshot" - -// def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" -// def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" -// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" - credentials { - username OSS_USERNAME - password OSS_PASSWORD - } - } - - maven { - name = "sonatype" - -// def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" -// def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" -// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - - credentials { - username OSS_USERNAME - password OSS_PASSWORD + scm { + connection = GIT_URL + developerConnection = GIT_URL + url = SITE_URL + } } } } } } -task androidJavadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - android.libraryVariants.all { variant -> - if (variant.name == 'release') { - owner.classpath += variant.javaCompileProvider.get().classpath - } - } - - exclude '**/R.html', '**/R.*.html', '**/index.html' - options.encoding 'utf-8' - options { - addStringOption 'docencoding', 'utf-8' - addStringOption 'charset', 'utf-8' - links 'https://docs.oracle.com/javase/7/docs/api/' - links 'https://d.android.com/reference' - links 'https://developer.android.com/reference/androidx/' - } -} - -task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { - archiveClassifier.set('javadoc') - from androidJavadoc.destinationDir - - preserveFileTimestamps = false - reproducibleFileOrder = true -} - -task javaSourcesJar(type: Jar) { - archiveClassifier.set('sources') - from android.sourceSets.main.java.srcDirs - - preserveFileTimestamps = false - reproducibleFileOrder = true -} From c1f725ad5bfaea80bfb0487af8ae2d533b060e10 Mon Sep 17 00:00:00 2001 From: ankitkumar Date: Fri, 26 Jan 2024 03:19:09 +0530 Subject: [PATCH 2/4] updated oss url --- build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.gradle b/build.gradle index 96ea28c..5a03e51 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,9 @@ nexusPublishing { username = System.getenv("OSS_USERNAME") password = System.getenv("OSS_PASSWORD") stagingProfileId = System.getenv("OSS_STAGING_PROFILE_ID") + + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) } } } \ No newline at end of file From 24791766411f40b94d86bd1e81df6239fd58a98e Mon Sep 17 00:00:00 2001 From: ankitkumar Date: Fri, 26 Jan 2024 03:24:20 +0530 Subject: [PATCH 3/4] updated version to test --- gradle/publish-package.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/publish-package.gradle b/gradle/publish-package.gradle index 7b32cd7..ce0c18d 100644 --- a/gradle/publish-package.gradle +++ b/gradle/publish-package.gradle @@ -3,7 +3,7 @@ apply plugin: 'signing' ext { GROUP_ID = "io.github.pseudoankit" - VERSION = "1.0.3" + VERSION = "1.0.4" SITE_URL = 'https://github.com/pseudoankit/coachmark' GIT_URL = 'https://github.com/pseudoankit/coachmark.git' From b64f00df376ecd27668b3c6ce8d814c90c3d7381 Mon Sep 17 00:00:00 2001 From: ankitkumar Date: Fri, 26 Jan 2024 18:00:39 +0530 Subject: [PATCH 4/4] added action --- .github/workflows/publish.yml | 31 +++++++++++++++++++++++++++++++ gradle/publish-package.gradle | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) 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..013d115 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,31 @@ +name: Publish + +on: + release: + types: [ created ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Check + run: ./gradlew check --stacktrace + + - name: Publish Artifact + run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --max-workers=1 --stacktrace + env: + RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} + OSS_USERNAME: ${{ secrets.OSS_USERNAME }} + OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }} + OSS_STAGING_PROFILE_ID: ${{ secrets.OSS_STAGING_PROFILE_ID }} + OSS_SIGNING_KEY_ID: ${{ secrets.OSS_SIGNING_KEY_ID }} + OSS_SIGNING_PASSWORD: ${{ secrets.OSS_SIGNING_PASSWORD }} + OSS_SIGNING_KEY: ${{ secrets.OSS_SIGNING_KEY }} \ No newline at end of file diff --git a/gradle/publish-package.gradle b/gradle/publish-package.gradle index ce0c18d..a81cc47 100644 --- a/gradle/publish-package.gradle +++ b/gradle/publish-package.gradle @@ -3,7 +3,7 @@ apply plugin: 'signing' ext { GROUP_ID = "io.github.pseudoankit" - VERSION = "1.0.4" + VERSION = (System.getenv("RELEASE_TAG_NAME") ?: "SNAPSHOT").replace("v", "") SITE_URL = 'https://github.com/pseudoankit/coachmark' GIT_URL = 'https://github.com/pseudoankit/coachmark.git'