Skip to content

Commit aa9aa7c

Browse files
committed
setup a generic deploy task
1 parent 5eff708 commit aa9aa7c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup Gradle
2626
uses: gradle/actions/setup-gradle@v3
2727
- name: Build
28-
run: ./gradlew --no-configuration-cache --no-parallel publish "-PsonatypeUsername=$SONATYPE_USERNAME" "-PsonatypePassword=$SONATYPE_PASSWORD"
28+
run: ./gradlew --no-configuration-cache --no-parallel mavenCentralDeploy "-PsonatypeUsername=$SONATYPE_USERNAME" "-PsonatypePassword=$SONATYPE_PASSWORD"
2929
env:
3030
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
3131
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,16 @@ val testAll by tasks.registering(DefaultTask::class) {
4949
this@registering.dependsOn(it)
5050
}
5151
}
52+
53+
val mavenCentralDeploy by tasks.registering(DefaultTask::class) {
54+
group = "publishing"
55+
val isSnapshot = project.version.toString().endsWith("-SNAPSHOT")
56+
57+
val publishTasks = subprojects
58+
.flatMap { it.tasks.withType<PublishToMavenRepository>() }
59+
.filter { it.repository.name == "sonatype" }
60+
dependsOn(publishTasks)
61+
if (!isSnapshot) {
62+
dependsOn(tasks.closeAndReleaseStagingRepositories)
63+
}
64+
}

0 commit comments

Comments
 (0)