Skip to content

Commit da9def9

Browse files
devcrocodCopilot
andauthored
Update CI workflows configuration for debugging (#172)
* Update CI workflows configuration for debugging * Update .github/workflows/gradle-publish.yml Co-authored-by: Copilot <[email protected]> * Refine Gradle and CI workflows for improved variable usage and error handling * Add validation for OSSRH credentials in Gradle publish workflow --------- Co-authored-by: Copilot <[email protected]>
1 parent ad31693 commit da9def9

File tree

3 files changed

+79
-17
lines changed

3 files changed

+79
-17
lines changed

.github/workflows/gradle-publish.yml

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name: Release
99

1010
on:
1111
release:
12-
types: [created]
12+
types: [ created ]
1313

1414
jobs:
1515
build:
@@ -27,12 +27,9 @@ jobs:
2727
with:
2828
java-version: '21'
2929
distribution: 'temurin'
30-
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
31-
server-username: JRELEASER_MAVENCENTRAL_USERNAME
32-
server-password: JRELEASER_MAVENCENTRAL_PASSWORD
3330

3431
- name: Setup Gradle
35-
uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1
32+
uses: gradle/actions/setup-gradle@v4
3633

3734
- name: Verify publication configuration
3835
run: ./gradlew jreleaserConfig
@@ -53,12 +50,80 @@ jobs:
5350
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
5451
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
5552

56-
- name: Publish to OSSRH repository
57-
run: ./gradlew publish jreleaserFullRelease
53+
- name: Publish to Maven Central Portal
54+
id: publish
55+
run: ./gradlew publish jreleaserFullRelease --info --stacktrace -Djreleaser.verbose=true
5856
env:
5957
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
6058
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
6159
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
6260
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
6361
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
6462
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Query Central Portal for validation errors
65+
if: failure()
66+
shell: bash
67+
env:
68+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
69+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
70+
run: |
71+
set -euo pipefail
72+
73+
OUTPUT_PROPS="build/jreleaser/output.properties"
74+
75+
if [[ ! -f "$OUTPUT_PROPS" ]]; then
76+
echo "::error title=File Missing::The file '$OUTPUT_PROPS' does not exist."
77+
exit 1
78+
fi
79+
80+
DEPLOY_ID=$(grep '^deploymentId=' "$OUTPUT_PROPS" | cut -d= -f2 || true)
81+
if [[ -z "$DEPLOY_ID" ]]; then
82+
echo "::error title=Missing Deployment ID::The 'deploymentId' key was not found in '$OUTPUT_PROPS'."
83+
exit 1
84+
fi
85+
86+
echo "Portal deploymentId: $DEPLOY_ID"
87+
88+
if [ -z "$OSSRH_USERNAME" ]; then
89+
echo "::error title='OSSRH_USERNAME' is not set."
90+
exit 1
91+
fi
92+
93+
if [ -z "$OSSRH_TOKEN" ]; then
94+
echo "::error title='OSSRH_TOKEN' is not set."
95+
exit 1
96+
fi
97+
98+
AUTH=$(printf "%s:%s" "$OSSRH_USERNAME" "$OSSRH_TOKEN" | base64)
99+
echo "::add-mask::$AUTH"
100+
101+
STATUS_JSON=$(curl -sS \
102+
-H "Authorization: Bearer $AUTH" \
103+
-H "Content-Type: application/json" \
104+
-X POST \
105+
"https://central.sonatype.com/api/v1/publisher/status?id=$DEPLOY_ID")
106+
107+
echo "$STATUS_JSON" | jq .
108+
109+
echo "$STATUS_JSON" | jq -r '.errors[]?.message' |
110+
while read -r MSG; do
111+
echo "::error title=Sonatype validation::$MSG"
112+
done
113+
114+
{
115+
echo "### Sonatype Central Portal validation result"
116+
echo
117+
echo '```json'
118+
echo "$STATUS_JSON"
119+
echo '```'
120+
} >> "$GITHUB_STEP_SUMMARY"
121+
122+
- name: Upload JReleaser artefacts
123+
if: always()
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: jreleaser-logs
127+
path: |
128+
build/jreleaser/trace.log
129+
build/jreleaser/output.properties

build.gradle.kts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ publishing {
4040

4141
jreleaser {
4242
gitRootSearch = true
43-
strict.set(true)
43+
strict = true
4444

4545
signing {
46-
active.set(Active.ALWAYS)
47-
armored.set(true)
48-
artifacts.set(true)
46+
active = Active.ALWAYS
47+
armored = true
48+
artifacts = true
4949
}
5050

5151
deploy {
@@ -138,13 +138,12 @@ fun MavenPom.configureMavenCentralMetadata() {
138138
}
139139

140140
fun MavenPublication.signPublicationIfKeyPresent() {
141-
val keyId = project.getSensitiveProperty("SIGNING_KEY_ID")
142141
val signingKey = project.getSensitiveProperty("SIGNING_KEY_PRIVATE")
143142
val signingKeyPassphrase = project.getSensitiveProperty("SIGNING_PASSPHRASE")
144143

145144
if (!signingKey.isNullOrBlank()) {
146145
the<SigningExtension>().apply {
147-
useInMemoryPgpKeys(keyId, signingKey, signingKeyPassphrase)
146+
useInMemoryPgpKeys(signingKey, signingKeyPassphrase)
148147

149148
sign(this@signPublicationIfKeyPresent)
150149
}

gradle.properties

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
kotlin.code.style=official
2-
#org.gradle.jvmargs=-XX:+UseParallelGC
3-
#org.gradle.parallel=true
4-
#org.gradle.configuration-cache.parallel=true
2+
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
3+
org.gradle.parallel=true
54
org.gradle.caching=true
6-
org.gradle.jvmargs=-Xmx4g
75

86
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
97
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

0 commit comments

Comments
 (0)