diff --git a/.github/workflows/monstera-publish.yml b/.github/workflows/monstera-publish.yml index c470504..339e8a1 100644 --- a/.github/workflows/monstera-publish.yml +++ b/.github/workflows/monstera-publish.yml @@ -6,7 +6,13 @@ on: jobs: build: - + env: + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} + JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.JRELEASER_MAVENCENTRAL_TOKEN }} runs-on: ubuntu-latest permissions: contents: read @@ -20,14 +26,17 @@ jobs: java-version: '11' distribution: 'temurin' - - name: Publish to Maven Central - uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + - name: Create Config + uses: gradle/gradle-build-action@v3 + with: + arguments: jreleaserConfig + + - name: Publish to local staging repo + uses: gradle/gradle-build-action@v3 + with: + arguments: publish + + - name: Release to Maven Central + uses: gradle/gradle-build-action@v3 with: - arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} - ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} - MAVEN_USER_NAME: ${{ secrets.MAVEN_USER_NAME }} - MAVEN_USER_PASSWORD: ${{ secrets.MAVEN_USER_PASSWORD }} + arguments: jreleaserFullRelease \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index fe3f892..7830461 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,13 @@ plugins { kotlin("jvm") version "2.0.0" - id("io.github.gradle-nexus.publish-plugin") version "2.0.0" `maven-publish` - signing + `java-library` + id("org.jreleaser") version "1.13.1" } -group = "com.lotsofpixelsstudios" -version = System.getenv("GITHUB_REF")?.removePrefix("refs/tags/") ?: "local" //use tag name as version +/*group = "com.lotsofpixelsstudios"*/ +group = "de.matthiasklenz" +version = System.getenv("GITHUB_REF")?.removePrefix("refs/tags/") ?: "0.5.0-SNAPSHOT1"//"0.1-local" //use tag name as version dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib") @@ -34,19 +35,6 @@ java { withSourcesJar() } -signing { - gradle.taskGraph.whenReady { - isRequired = allTasks.any { it is PublishToMavenRepository } - } - - useInMemoryPgpKeys( - System.getenv("ORG_GRADLE_PROJECT_signingKey"), - System.getenv("ORG_GRADLE_PROJECT_signingPassword") - ) - - sign(publishing.publications) -} - //set the version in the resource files to access it from projects gradle.taskGraph.whenReady { layout @@ -72,13 +60,27 @@ repositories { mavenCentral() } -nexusPublishing { - repositories { - sonatype { //only for users registered in Sonatype after 24 Feb 2021 - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - username = System.getenv("MAVEN_USER_NAME") - password = System.getenv("MAVEN_USER_PASSWORD") +jreleaser { + release { + github { + skipTag = true + skipRelease = true + } + } + signing { + setActive("ALWAYS") + armored = true + } + deploy { + maven { + //Portal Publisher API + mavenCentral { + register("sonatype") { + setActive("ALWAYS") + url = "https://central.sonatype.com/api/v1/publisher" + stagingRepository(layout.buildDirectory.dir("staging-deploy").get().asFile.path) + } + } } } } @@ -111,4 +113,9 @@ publishing { } } } + repositories { + maven { + url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI() + } + } }