Skip to content

Commit a4145a8

Browse files
build: automate the Gradle publishToMavenCentral task
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent dde53c0 commit a4145a8

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
runs-on: ${{ matrix.os }}
4040
strategy:
4141
matrix:
42-
# os: [ ubuntu-latest, windows-latest, macos-latest ]
43-
os: [ ubuntu-latest, macos-latest ]
42+
# os: [ ubuntu-latest, windows-latest, macos-latest ]
43+
os: [ ubuntu-latest, macos-latest ]
4444
steps:
4545
- uses: actions/checkout@main
4646
with:
@@ -75,10 +75,20 @@ jobs:
7575
uses: gradle/actions/setup-gradle@main
7676

7777
- name: Publish with Gradle
78-
run: ./gradlew publish
78+
# Gradle only picks up a secret as a project property when it is exported with the
79+
# ORG_GRADLE_PROJECT_ prefix. Plain `ossrhUsername: ...` was an ordinary environment
80+
# variable that nothing ever read.
81+
#
82+
# No RELEASE variable here on purpose: getVersion() then produces a -SNAPSHOT version and
83+
# the plugin routes it to the Central Portal snapshot repository. Set RELEASE=true only
84+
# when you actually intend to cut a release.
85+
run: ./gradlew publishToMavenCentral
7986
env:
80-
ossrhUsername: ${{ secrets.OSSRHUSERNAME }}
81-
ossrhPassword: ${{ secrets.OSSRHPASSWORD }}
87+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.mavenCentralUsername }}
88+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.mavenCentralPassword }}
89+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.signingInMemoryKey }}
90+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.signingInMemoryKeyId }}
91+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.signingInMemoryKeyPassword }}
8292

8393
- uses: actions/setup-python@main
8494

@@ -101,4 +111,4 @@ jobs:
101111

102112
- name: Deploy to GitHub Pages
103113
id: deployment
104-
uses: actions/deploy-pages@main
114+
uses: actions/deploy-pages@main

‎build.gradle‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,9 @@ tasks.register('sphinx', Exec) {
589589
}
590590
}
591591

592-
publish {
592+
// `publish` is Gradle's own task; the Central Portal upload runs under `publishToMavenCentral`.
593+
// Both need the same prerequisites, or a CI job invoking the latter silently skips check and docs.
594+
tasks.matching { it.name in ['publish', 'publishToMavenCentral'] }.configureEach {
593595
dependsOn(check, gitChangelogTask, renderRR, xslt, xmldoc)
594596
}
595597

@@ -636,14 +638,9 @@ mavenPublishing {
636638
}
637639
}
638640

639-
// Fix signing task dependencies
640-
tasks.withType(AbstractPublishToMaven).configureEach {
641-
dependsOn(tasks.withType(Sign))
642-
}
643-
644-
signing {
645-
required { !version.endsWith("SNAPSHOT") && gradle.taskGraph.hasTask("publish") }
646-
}
641+
// Signing and its task wiring are handled by mavenPublishing.signAllPublications() above.
642+
// The manual `signing { required { ... hasTask("publish") } }` block that used to live here
643+
// never matched the `publishToMavenCentral` task, so the two disagreed about whether to sign.
647644

648645
tasks.withType(JavaCompile).configureEach {
649646
options.encoding = 'UTF-8'

0 commit comments

Comments
 (0)