|
| 1 | +# Publishing to Maven Central |
| 2 | + |
| 3 | +This document describes the new publishing process for EDUX library to Maven Central using the new Central Portal API. |
| 4 | + |
| 5 | +## Background |
| 6 | + |
| 7 | +As of November 2024, OSSRH (OSS Repository Hosting) reached end of life and was shut down. We have migrated from the legacy OSSRH staging API to the new Central Portal publishing method. |
| 8 | + |
| 9 | +**Official Statement:** https://central.sonatype.org/pages/ossrh-eol/ |
| 10 | + |
| 11 | +## New Publishing Method |
| 12 | + |
| 13 | +We now use the `com.gradleup.nmcp` Gradle plugin, which provides integration with the new Maven Central Portal API. |
| 14 | + |
| 15 | +### Configuration |
| 16 | + |
| 17 | +The publishing configuration is in `lib/build.gradle`: |
| 18 | + |
| 19 | +```gradle |
| 20 | +plugins { |
| 21 | + // ... other plugins |
| 22 | + id 'com.gradleup.nmcp' version '0.0.8' |
| 23 | +} |
| 24 | +
|
| 25 | +nmcp { |
| 26 | + publish("mavenJava") { |
| 27 | + username = System.getenv("MAVEN_CENTRAL_USERNAME") |
| 28 | + password = System.getenv("MAVEN_CENTRAL_PASSWORD") |
| 29 | + publicationType = "USER_MANAGED" // Manual release control |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +### Required Secrets |
| 35 | + |
| 36 | +The following GitHub secrets must be configured: |
| 37 | + |
| 38 | +1. **MAVEN_CENTRAL_USERNAME**: Username from Central Portal token |
| 39 | +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 |
| 42 | + |
| 43 | +### Central Portal Token Generation |
| 44 | + |
| 45 | +1. Go to https://central.sonatype.com/account |
| 46 | +2. Generate a user token |
| 47 | +3. Use the generated username/password for `MAVEN_CENTRAL_USERNAME` and `MAVEN_CENTRAL_PASSWORD` |
| 48 | + |
| 49 | +### Publishing Process |
| 50 | + |
| 51 | +#### Automated (GitHub Actions) |
| 52 | +- Automatic publishing occurs on pushes to `main` branch |
| 53 | +- GitHub Action runs: `./gradlew publishAllPublicationsToNmcpMavenJavaRepository` |
| 54 | +- With `USER_MANAGED` setting, releases require manual approval on Central Portal |
| 55 | + |
| 56 | +#### Manual Publishing |
| 57 | +```bash |
| 58 | +# Publish to Central Portal |
| 59 | +./gradlew publishAllPublicationsToNmcpMavenJavaRepository |
| 60 | + |
| 61 | +# Check available tasks |
| 62 | +./gradlew tasks --all | grep nmcp |
| 63 | +``` |
| 64 | + |
| 65 | +### Publication Type Options |
| 66 | + |
| 67 | +- **USER_MANAGED**: Artifacts are uploaded but require manual release approval in Central Portal |
| 68 | +- **AUTOMATIC**: Artifacts are automatically published after validation |
| 69 | + |
| 70 | +### Verification |
| 71 | + |
| 72 | +After publishing with `USER_MANAGED`: |
| 73 | +1. Log into https://central.sonatype.com/ |
| 74 | +2. Navigate to deployments |
| 75 | +3. Review and approve the deployment for public release |
| 76 | + |
| 77 | +### Migration Changes |
| 78 | + |
| 79 | +- ✅ Removed legacy OSSRH repository configuration |
| 80 | +- ✅ Added `com.gradleup.nmcp` plugin |
| 81 | +- ✅ Updated GitHub Actions workflow |
| 82 | +- ✅ Fixed JUnit test dependencies (unrelated but needed for build) |
| 83 | + |
| 84 | +### Troubleshooting |
| 85 | + |
| 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) |
| 88 | +- Check Central Portal deployment status at https://central.sonatype.com/ |
0 commit comments