Skip to content

Commit e5a4b47

Browse files
committed
Reapply "chore: publish to maven central"
This reverts commit 4ce82f3.
1 parent 4ce82f3 commit e5a4b47

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ jobs:
100100
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USER }}
101101
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
102102
run: |
103-
./gradlew clean publishAllPublicationsToMavenCentralRepository
103+
set -euo pipefail
104+
if [[ "${{ steps.getVersion.outputs.releaseVersion }}" == *SNAPSHOT ]]; then
105+
./gradlew clean publishAllPublicationsToMavenCentralRepository
106+
else
107+
./gradlew clean publishReleaseToMavenCentral
108+
fi
104109
105110
publishRelease:
106111
runs-on: ubuntu-latest

build.gradle

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ plugins {
2121
id 'com.github.johnrengelman.shadow' version '8.1.1'
2222
id 'org.sonarqube' version '5.1.0.4882'
2323
id 'team.yi.semantic-gitlog' version '0.6.12'
24+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
2425
}
2526

2627
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
@@ -194,7 +195,33 @@ apply from: 'gradle/release.gradle'
194195
apply from: 'gradle/staticCodeCheck.gradle'
195196
apply from: 'gradle/changelog.gradle'
196197

197-
// ############ Annotation Processing
198+
// See: https://github.com/gradle-nexus/publish-plugin
199+
nexusPublishing {
200+
repositories {
201+
sonatype {
202+
// Align with the URLs used in gradle/publishing.gradle
203+
nexusUrl.set(uri('https://ossrh-staging-api.central.sonatype.com/service/local/'))
204+
snapshotRepositoryUrl.set(uri('https://central.sonatype.com/repository/maven-snapshots/'))
205+
username.set(findProperty('mavenCentralUsername')?.toString())
206+
password.set(findProperty('mavenCentralPassword')?.toString())
207+
}
208+
}
209+
}
210+
211+
tasks.register('publishReleaseToMavenCentral') {
212+
group = 'publishing'
213+
description = 'Publish a release build to Sonatype and close+release the staging repository (Maven Central).'
214+
215+
doLast {
216+
if (String.valueOf(project.version).endsWith('-SNAPSHOT')) {
217+
throw new GradleException('publishReleaseToMavenCentral must be run with a non-SNAPSHOT version')
218+
}
219+
}
220+
}
221+
222+
publishReleaseToMavenCentral.dependsOn('publishToSonatype')
223+
publishReleaseToMavenCentral.dependsOn('closeAndReleaseSonatypeStagingRepository')
224+
198225

199226
task annotationProcessing(type: JavaCompile, group: 'build') {
200227
options.annotationProcessorPath = configurations.annotationProcessor

0 commit comments

Comments
 (0)