From f393bac30f2c001c1ca575bff743946f4b27eeec Mon Sep 17 00:00:00 2001 From: Oleg Yakovlev Date: Fri, 26 Mar 2021 15:36:04 +0700 Subject: [PATCH] Publish to Maven Central --- .github/workflows/distribution.yml | 16 +++++--- README.md | 4 +- fcm-push-service/build.gradle.kts | 60 +++++++++++++++++++++++++++--- 3 files changed, 68 insertions(+), 12 deletions(-) diff --git a/.github/workflows/distribution.yml b/.github/workflows/distribution.yml index 3557eca..38fc827 100644 --- a/.github/workflows/distribution.yml +++ b/.github/workflows/distribution.yml @@ -1,17 +1,23 @@ -name: Bintray Distribution +name: Maven Central Distribution on: release: - types: [published] + types: [ published ] jobs: gradle: strategy: matrix: - os: [ubuntu-latest] + os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - uses: actions/setup-java@v1 with: java-version: 11 - - name: Build and publish to Bintray - run: ./gradlew :fcm-push-service:publish -DBINTRAY_USER=${{ secrets.BINTRAY_USER }} -DBINTRAY_KEY=${{ secrets.BINTRAY_KEY }} -PlibraryPublish + - name: Build and publish to mavenCentral + env: + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_KEY: ${{ secrets.OSSRH_KEY }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEYID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.GPG_KEY_CONTENTS }} + run: ./gradlew publish -PlibraryPublish diff --git a/README.md b/README.md index 7f9957d..8a3a2ac 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ ````kotlin // Append repository repositories { - maven { url = url("https://dl.bintray.com/icerockdev/backend") } + mavenCentral() } // Append dependency -implementation("com.icerockdev.service:fcm-push-service:0.1.0") +implementation("com.icerockdev.service:fcm-push-service:0.1.1") ```` ## Koin configure diff --git a/fcm-push-service/build.gradle.kts b/fcm-push-service/build.gradle.kts index 6e2680a..1f95174 100644 --- a/fcm-push-service/build.gradle.kts +++ b/fcm-push-service/build.gradle.kts @@ -1,15 +1,18 @@ +import java.util.Base64 +import kotlin.text.String /* * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ group = "com.icerockdev.service" -version = "0.1.0" +version = "0.1.1" plugins { id("org.jetbrains.kotlin.jvm") id("kotlin-kapt") id("maven-publish") id("java-library") + id("signing") } apply(plugin = "kotlin") @@ -39,6 +42,7 @@ dependencies { java { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 + withJavadocJar() } tasks.withType { @@ -52,18 +56,64 @@ repositories { } publishing { - repositories.maven("https://api.bintray.com/maven/icerockdev/backend/fcm-push-service/;publish=1") { - name = "bintray" + repositories.maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { + name = "OSSRH" credentials { - username = System.getProperty("BINTRAY_USER") - password = System.getProperty("BINTRAY_KEY") + username = System.getenv("OSSRH_USER") + password = System.getenv("OSSRH_KEY") } } publications { register("mavenJava", MavenPublication::class) { from(components["java"]) artifact(sourcesJar.get()) + pom { + name.set("Fcm push service") + description.set("Tools for sending fcm push by kotlin") + url.set("https://github.com/icerockdev/fcm-push-service") + licenses { + license { + url.set("https://github.com/icerockdev/fcm-push-service/blob/master/LICENSE.md") + } + } + + developers { + developer { + id.set("YokiToki") + name.set("Stanislav") + email.set("skarakovski@icerockdev.com") + } + + developer { + id.set("AlexeiiShvedov") + name.set("Alex Shvedov") + email.set("ashvedov@icerockdev.com") + } + + developer { + id.set("oyakovlev") + name.set("Oleg Yakovlev") + email.set("oyakovlev@icerockdev.com") + } + } + + scm { + connection.set("scm:git:ssh://github.com/icerockdev/fcm-push-service.git") + developerConnection.set("scm:git:ssh://github.com/icerockdev/fcm-push-service.git") + url.set("https://github.com/icerockdev/fcm-push-service") + } + } + } + + signing { + val signingKeyId: String? = System.getenv("SIGNING_KEY_ID") + val signingPassword: String? = System.getenv("SIGNING_PASSWORD") + val signingKey: String? = System.getenv("SIGNING_KEY")?.let { base64Key -> + String(Base64.getDecoder().decode(base64Key)) + } + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) + sign(publishing.publications["mavenJava"]) } } }