Skip to content

Commit 71cb763

Browse files
committed
simplify GPG credential passing via environment variables in publish workflows
1 parent 0d3cc57 commit 71cb763

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
pull_request:
44
branches:
55
- master
6+
workflow_dispatch:
67
jobs:
78
maven-package:
89
runs-on: ubuntu-24.04

.github/workflows/release.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,6 @@ jobs:
6666
echo "MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME=$MVN_USER"
6767
echo "MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD=$MVN_PASS"
6868
} >> "$GITHUB_ENV"
69-
- name: Setup GPG and JReleaser credentials
70-
run: |
71-
echo "$MAVEN_GPG_PRIVATE_KEY" | gpg --batch --import
72-
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep '^sec' | awk '{print $2}' | cut -d'/' -f2 | head -1)
73-
{
74-
echo "JRELEASER_GPG_PUBLIC_KEY<<GPG_EOF"
75-
gpg --armor --export "$GPG_KEY_ID"
76-
echo "GPG_EOF"
77-
echo "JRELEASER_GPG_SECRET_KEY<<GPG_EOF"
78-
gpg --armor --export-secret-keys "$GPG_KEY_ID"
79-
echo "GPG_EOF"
80-
echo "JRELEASER_GPG_PASSPHRASE=$MAVEN_GPG_PASSPHRASE"
81-
echo "JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME=$MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME"
82-
echo "JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD=$MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD"
83-
} >> "$GITHUB_ENV"
8469
- name: Stage artifacts
8570
run: mvn deploy -Ppublication -Dprettier.skip=true
8671
- name: Deploy to Maven Central
@@ -89,6 +74,8 @@ jobs:
8974
# jreleaser:deploy only handles Maven Central; GitHub release management is done by the GitHub UI.
9075
env:
9176
JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_PUBLISHING_TYPE: ${{ github.event.action == 'prereleased' && 'USER_MANAGED' || 'AUTOMATIC' }}
77+
JRELEASER_GPG_PASSPHRASE: ${{ env.MAVEN_GPG_PASSPHRASE }}
78+
JRELEASER_GPG_SECRET_KEY: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
9279
run: mvn jreleaser:deploy -Djreleaser.output.directory=out
9380
- name: Upload CLI fat jar to GitHub release
9481
run: |

pom.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<tag>HEAD</tag>
5353
</scm>
5454
<properties>
55-
<jreleaser-maven-plugin.version>1.20.0</jreleaser-maven-plugin.version>
55+
<jreleaser-maven-plugin.version>1.23.0</jreleaser-maven-plugin.version>
5656
<sonar-maven-plugin.version>5.2.0.4988</sonar-maven-plugin.version>
5757
<prettier-java.version>2.1.0</prettier-java.version>
5858
<prettier-maven-plugin.version>0.22</prettier-maven-plugin.version>
@@ -69,6 +69,11 @@
6969
<signing>
7070
<active>ALWAYS</active>
7171
<armored>true</armored>
72+
<!-- verify=false: skips local signature verification after signing.
73+
Maven Central performs its own verification on upload, so this
74+
is redundant locally and requires BouncyCastle to re-parse the
75+
public key, which fails in some JReleaser versions. -->
76+
<verify>false</verify>
7277
</signing>
7378
<deploy>
7479
<maven>
@@ -77,6 +82,8 @@
7782
<active>RELEASE</active>
7883
<url>https://central.sonatype.com/api/v1/publisher</url>
7984
<stagingRepositories>target/staging-deploy</stagingRepositories>
85+
<username>${env.MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME}</username>
86+
<password>${env.MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD}</password>
8087
</sonatype>
8188
</mavenCentral>
8289
<nexus2>
@@ -89,6 +96,8 @@
8996
<closeRepository>true</closeRepository>
9097
<releaseRepository>true</releaseRepository>
9198
<stagingRepositories>target/staging-deploy</stagingRepositories>
99+
<username>${env.MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME}</username>
100+
<password>${env.MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD}</password>
92101
</maven-central>
93102
</nexus2>
94103
</maven>

0 commit comments

Comments
 (0)