Skip to content

Commit

Permalink
Switch to maven central publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
rubengees committed Sep 6, 2024
1 parent 0a9a282 commit baf53cf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 72 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ jobs:
run: ./gradlew check

- name: Publish
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
run: ./gradlew publishToMavenCentral
env:
OSSRHUSER: ${{ secrets.OSSRHUSER }}
OSSRHPASSWORD: ${{ secrets.OSSRHPASSWORD }}
GITHUB_VERSION: ${{ github.event.release.tag_name }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }}

- name: Upload Gradle reports
uses: actions/upload-artifact@v4
Expand Down
108 changes: 41 additions & 67 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("signing")
id("maven-publish")
kotlin("jvm") version "1.9.22"
id("org.jetbrains.dokka") version "1.9.10"
id("io.gitlab.arturbosch.detekt") version "1.23.4"
id("org.jmailen.kotlinter") version "4.2.0"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("com.vanniktech.maven.publish") version "0.29.0"
id("com.github.ben-manes.versions") version "0.50.0"
}

Expand Down Expand Up @@ -53,9 +52,6 @@ dependencies {
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

withJavadocJar()
withSourcesJar()
}

kotlin {
Expand All @@ -71,10 +67,6 @@ detekt {
buildUponDefaultConfig = true
}

tasks.named<Jar>("javadocJar") {
from(tasks.named("dokkaJavadoc"))
}

tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
externalDocumentationLink("https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/latest/")
Expand Down Expand Up @@ -102,66 +94,48 @@ fun isNonStable(version: String): Boolean {
return !isStable
}

publishing {
publications {
create<MavenPublication>("maven") {
artifactId = "socket-io-redis-emitter"

from(components["java"])

pom {
name = "Socket-io-Redis-Emitter"
description = "Library to emit socket.io notifications via redis."
url = "https://github.com/SmartsquareGmbH/socket-io-redis-emitter"

licenses {
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
}
}
developers {
developer {
id = "deen13"
name = "Dennis Dierkes"
email = "[email protected]"
}
}
scm {
connection = "scm:git:https://github.com/SmartsquareGmbH/socket-io-redis-emitter.git"
developerConnection = "scm:git:ssh://github.com/SmartsquareGmbH/socket-io-redis-emitter.git"
url = "https://github.com/SmartsquareGmbH/socket-io-redis-emitter"
}
organization {
name = "Smartsquare GmbH"
url = "https://github.com/SmartsquareGmbH"
}
issueManagement {
system = "GitHub"
url = "https://github.com/SmartsquareGmbH/socket-io-redis-emitter/issues"
}
mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
signAllPublications()

pom {
name = "Socket-io-Redis-Emitter"
description = "Library to emit socket.io notifications via redis."
url = "https://github.com/SmartsquareGmbH/socket-io-redis-emitter"
inceptionYear = "2021"

licenses {
license {
name = "MIT License"
url = "https://opensource.org/license/mit"
distribution = "https://opensource.org/license/mit"
}
}
}
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = project.findProperty("gpr.ossrhUser")?.toString() ?: System.getenv("OSSRHUSER")
password = project.findProperty("gpr.ossrhPassword")?.toString() ?: System.getenv("OSSRHPASSWORD")
developers {
developer {
id = "deen13"
name = "Dennis Dierkes"
email = "[email protected]"
}
developer {
id = "rubengees"
name = "Ruben Gees"
email = "[email protected]"
}
}
scm {
connection = "scm:git:https://github.com/SmartsquareGmbH/socket-io-redis-emitter.git"
developerConnection = "scm:git:ssh://github.com/SmartsquareGmbH/socket-io-redis-emitter.git"
url = "https://github.com/SmartsquareGmbH/socket-io-redis-emitter"
}
organization {
name = "Smartsquare GmbH"
url = "https://github.com/SmartsquareGmbH"
}
issueManagement {
system = "GitHub"
url = "https://github.com/SmartsquareGmbH/socket-io-redis-emitter/issues"
}
}
}

signing {
if (!version.toString().endsWith("SNAPSHOT")) {
val signingKey = findProperty("signingKey")?.toString() ?: System.getenv("GPG_PRIVATE_KEY")
val signingPassword = findProperty("signingPassword")?.toString() ?: System.getenv("GPG_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
}

Expand Down

0 comments on commit baf53cf

Please sign in to comment.