diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index ea52b0c..35641f4 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 6a6fb81..6f5fdf4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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" @@ -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. @@ -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("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") - } - } -}