Skip to content

Commit 9deb20c

Browse files
SamyssmileSamuel Abramov
andauthored
migrating to new publish pipeline (#185)
Co-authored-by: Samuel Abramov <info@abramov-samuel.de>
1 parent c5737dc commit 9deb20c

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

PUBLISHING.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,30 @@ nmcp {
3131
}
3232
```
3333

34-
### Required Secrets
34+
### Required Environment Variables
3535

36-
The following GitHub secrets must be configured:
36+
For local development and CI/CD, the following environment variables must be set:
3737

3838
1. **MAVEN_CENTRAL_USERNAME**: Username from Central Portal token
3939
2. **MAVEN_CENTRAL_PASSWORD**: Password from Central Portal token
40-
3. **SIGNING_KEY**: GPG private key for artifact signing
41-
4. **SIGNING_PASSWORD**: GPG key passphrase
40+
3. **GPG_PRIVATE_KEY**: GPG private key for artifact signing (complete PGP block)
41+
4. **GPG_PASSPHRASE**: GPG key passphrase
42+
43+
### Local Development Setup
44+
45+
Use the provided setup script:
46+
```bash
47+
# Source the environment variables
48+
source setup-publishing-env.sh
49+
50+
# Test local publishing first
51+
./gradlew lib:publishMavenJavaPublicationToMavenLocal
52+
53+
# Publish to Central Portal
54+
./gradlew lib:publish
55+
# or
56+
./gradlew lib:publishAllPublicationsToCentralPortal
57+
```
4258

4359
### Central Portal Token Generation
4460

@@ -81,8 +97,29 @@ After publishing with `USER_MANAGED`:
8197
- ✅ Updated GitHub Actions workflow
8298
- ✅ Fixed JUnit test dependencies (unrelated but needed for build)
8399

100+
### GPG Signing Configuration
101+
102+
The build now supports both in-memory GPG signing and GPG command-line tool:
103+
104+
```gradle
105+
signing {
106+
required { gradle.taskGraph.hasTask("publish") }
107+
def signingKey = System.getenv("GPG_PRIVATE_KEY")
108+
def signingPassword = System.getenv("GPG_PASSPHRASE")
109+
110+
if (signingKey && signingPassword) {
111+
useInMemoryPgpKeys(signingKey, signingPassword) // Preferred for CI/CD
112+
} else {
113+
useGpgCmd() // Fallback to local GPG installation
114+
}
115+
sign publishing.publications.mavenJava
116+
}
117+
```
118+
84119
### Troubleshooting
85120

86-
- Ensure all required secrets are configured in GitHub repository settings
87-
- Verify GPG signing key is properly formatted (include `-----BEGIN PGP PRIVATE KEY BLOCK-----` headers)
121+
- **GPG Error "finished with non-zero exit value 2"**: Use the provided `setup-publishing-env.sh` script to set environment variables for in-memory GPG signing
122+
- Ensure all required environment variables are set before publishing
123+
- Verify GPG private key is properly formatted (include `-----BEGIN PGP PRIVATE KEY BLOCK-----` headers)
124+
- Test local publishing first: `./gradlew lib:publishMavenJavaPublicationToMavenLocal`
88125
- Check Central Portal deployment status at https://central.sonatype.com/

lib/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ publishing {
101101

102102
signing {
103103
required { gradle.taskGraph.hasTask("publish") }
104-
useGpgCmd()
104+
def signingKey = System.getenv("GPG_PRIVATE_KEY")
105+
def signingPassword = System.getenv("GPG_PASSPHRASE")
106+
107+
if (signingKey && signingPassword) {
108+
useInMemoryPgpKeys(signingKey, signingPassword)
109+
} else {
110+
useGpgCmd()
111+
}
105112
sign publishing.publications.mavenJava
106113
}
107114

0 commit comments

Comments
 (0)