From 319d00031eec6a2856ec7538037d8db4c0d199c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Sv=C4=9Bcen=C3=BD?= Date: Wed, 20 Apr 2022 16:05:54 +0200 Subject: [PATCH] Release package to Gradle public registry, remove support for GitHub packages --- .github/workflows/publish.yml | 11 +++-- hubspot/build.gradle.kts | 83 ++++++++++++++++++++++++++++------- 2 files changed, 76 insertions(+), 18 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 128f073..161c474 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,8 +26,13 @@ jobs: - name: Publish library env: - GITHUB_RELEASE: ${{ github.event.release.tag_name }} - GITHUB_TOKEN: ${{ secrets.GRADLE_PUBLISH_TOKEN }} - GITHUB_USERNAME: ${{ secrets.GRADLE_PUBLISH_USER }} + # Gradle GPG Keys + GRADLE_GPG_SIGN_KEY: ${{ secrets.GRADLE_GPG_SIGN_KEY }} + GRADLE_GPG_SIGN_PASSWORD: ${{ secrets.GRADLE_GPG_SIGN_PASSWORD }} + + # Sonatype + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: ./gradlew publish working-directory: ./hubspot diff --git a/hubspot/build.gradle.kts b/hubspot/build.gradle.kts index 117c790..7b777cc 100644 --- a/hubspot/build.gradle.kts +++ b/hubspot/build.gradle.kts @@ -3,12 +3,14 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.6.10" + // https://github.com/gradle-nexus/publish-plugin + id("io.github.gradle-nexus.publish-plugin") version "1.1.0" id("maven-publish") + id("signing") } -group = "com.goforboom" -version = "0.0.1" - +group = "com.goforboom.hubspot" +version = "1.0.0" java.sourceCompatibility = JavaVersion.VERSION_11 java.targetCompatibility = JavaVersion.VERSION_11 @@ -33,27 +35,78 @@ dependencies { testImplementation("org.mockito.kotlin:mockito-kotlin:3.2.0") } +java { + withSourcesJar() + withJavadocJar() +} + +signing { + val signingKey: String = System.getenv("GRADLE_GPG_SIGN_KEY") + val signingPassword: String = System.getenv("GRADLE_GPG_SIGN_PASSWORD") + + useInMemoryPgpKeys(signingKey, signingPassword) + + sign(publishing.publications) +} + + publishing { publications { - create("kotlin") { - groupId = "com.goforboom" - artifactId = "hubspot" + create("sdk") { + groupId = "com.goforboom.hubspot" + artifactId = "sdk" version = version + pom { + version = version + name.set("HubSpot SDK") + description.set("Implementation of HubSpot API for Java/Kotlin in tiny SDK") + url.set("https://github.com/goforboom/hubspot") + + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + + developers { + developer { + id.set("goforboom") + name.set("BOOM") + email.set("dev@goforboom.com") + } + } + + scm { + connection.set("scm:git:git://github.com:goforboom/hubspot.git") + developerConnection.set("scm:git:ssh://github.com:goforboom/hubspot.git") + url.set("https://github.com/goforboom/hubspot") + } + } + from(components["java"]) } } +} +nexusPublishing { repositories { - maven { - name = "goforboom" - url = uri("https://maven.pkg.github.com/goforboom/hubspot") - credentials { - - // Credentials for GitHub package publish - username = System.getenv("GITHUB_USERNAME") - password = System.getenv("GITHUB_TOKEN") - } + create("sdk") { + nexusUrl.set( + uri("https://s01.oss.sonatype.org/service/local/") + ) + + snapshotRepositoryUrl.set( + uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") + ) + + username.set( + System.getenv("SONATYPE_USERNAME") + ) + password.set( + System.getenv("SONATYPE_PASSWORD") + ) } } }