Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:

- name: Publish Plugin Release
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew publish closeAndReleaseStagingRepositories
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew publishToMavenCentral
92 changes: 28 additions & 64 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

plugins {
`java-gradle-plugin`
`maven-publish`
signing
kotlin("jvm") version "2.2.0"
id("io.kotest.multiplatform") version "5.9.1"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("com.vanniktech.maven.publish") version "0.34.0"
}

group = "xyz.atrius"
Expand All @@ -32,6 +30,33 @@ kotlin {
jvmToolchain(17)
}

mavenPublishing {
publishToMavenCentral(automaticRelease = true)
signAllPublications()

coordinates(
groupId = group as String,
artifactId = rootProject.name,
version = property("version") as String
)

pom {
val projectWebsite: String by project
val license: String by project
val licenseLink: String by project

name = rootProject.name
url = projectWebsite

licenses {
license {
name = license
url = licenseLink
}
}
}
}

gradlePlugin {
// Since we provide two plugins together that we want deployed as a single plugin, we should disable this to avoid
// publishing either of them separately when running through deployment pipelines.
Expand All @@ -55,64 +80,3 @@ gradlePlugin {
}
}
}

publishing {
// Maven Central repository configuration
repositories {
maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
name = "MavenCentral"

credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
// Both plugins should be deployed as a single artifact to ensure they can be setup automatically
publications {

val projectWebsite: String by project
val license: String by project
val licenseLink: String by project

create<MavenPublication>("Compositor") {
from(components["java"])

groupId = group.toString()
artifactId = rootProject.name
version = property("version") as String

pom {
name = rootProject.name
url = projectWebsite

licenses {
license {
name = license
url = licenseLink
}
}
}
}
}
}
// Maven Central requires artifacts to be signed for upload
signing {
val signingKey = System.getenv("SINGING_KEY")
val signingPassword = System.getenv("SIGNING_PASSWORD")

if (!signingKey.isNullOrEmpty()) {
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
}
// Maven Central apparently requires staging repositories to be closed before a release can be published
// This should configure the plugin which will automate this process in the deployment pipeline
nexusPublishing {
repositories {
sonatype {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}