From aa9aa7c273b4a6da6d6a5a6a250a73c28df2e48c Mon Sep 17 00:00:00 2001 From: Phillip Schichtel Date: Wed, 3 Jul 2024 21:32:09 +0200 Subject: [PATCH] setup a generic deploy task --- .github/workflows/gradle.yml | 2 +- build.gradle.kts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a4428be..4563e4f 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -25,7 +25,7 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 - name: Build - run: ./gradlew --no-configuration-cache --no-parallel publish "-PsonatypeUsername=$SONATYPE_USERNAME" "-PsonatypePassword=$SONATYPE_PASSWORD" + run: ./gradlew --no-configuration-cache --no-parallel mavenCentralDeploy "-PsonatypeUsername=$SONATYPE_USERNAME" "-PsonatypePassword=$SONATYPE_PASSWORD" env: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} diff --git a/build.gradle.kts b/build.gradle.kts index 9907cd0..4d6e75a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -49,3 +49,16 @@ val testAll by tasks.registering(DefaultTask::class) { this@registering.dependsOn(it) } } + +val mavenCentralDeploy by tasks.registering(DefaultTask::class) { + group = "publishing" + val isSnapshot = project.version.toString().endsWith("-SNAPSHOT") + + val publishTasks = subprojects + .flatMap { it.tasks.withType() } + .filter { it.repository.name == "sonatype" } + dependsOn(publishTasks) + if (!isSnapshot) { + dependsOn(tasks.closeAndReleaseStagingRepositories) + } +}