|
| 1 | +# JReleaser Maven Central Setup |
| 2 | + |
| 3 | +This project has been converted to use [JReleaser](https://jreleaser.org/) for automated releases to Maven Central via the Portal Publisher API. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +JReleaser simplifies the release process by: |
| 8 | +- Automating version bumping and git tagging |
| 9 | +- Building and signing artifacts |
| 10 | +- Publishing to Maven Central using the new Portal API |
| 11 | +- Creating GitHub releases with changelog |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +Before performing a release, ensure you have: |
| 16 | + |
| 17 | +1. **Maven Central Portal API Credentials** |
| 18 | + - Set environment variable: `JRELEASER_MAVENCENTRAL_USERNAME` (your Sonatype token username) |
| 19 | + - Set environment variable: `JRELEASER_MAVENCENTRAL_PASSWORD` (your Sonatype token password) |
| 20 | + - Get these from: https://central.sonatype.com/account |
| 21 | + |
| 22 | +2. **GPG Signing Setup** |
| 23 | + - Export your GPG secret key in base64: |
| 24 | + ```bash |
| 25 | + gpg --export-secret-keys <key-id> | base64 |
| 26 | + ``` |
| 27 | + - Set environment variable: `JRELEASER_GPG_SECRET_KEY` with the base64-encoded key |
| 28 | + - Set environment variable: `JRELEASER_GPG_PASSPHRASE` with your GPG passphrase |
| 29 | + |
| 30 | + OR use a key file: |
| 31 | + ```bash |
| 32 | + export JRELEASER_GPG_SECRET_KEY_FILE=~/.gnupg/secring.gpg |
| 33 | + export JRELEASER_GPG_PASSPHRASE=<your-passphrase> |
| 34 | + ``` |
| 35 | + |
| 36 | +3. **GitHub Token** (optional, for creating releases) |
| 37 | + - Set environment variable: `JRELEASER_GITHUB_TOKEN` with a GitHub personal access token |
| 38 | + |
| 39 | +## Release Process |
| 40 | + |
| 41 | +### 1. Prepare for Release |
| 42 | +Update version in `gradle.properties`: |
| 43 | +```properties |
| 44 | +version=X.Y.Z |
| 45 | +``` |
| 46 | + |
| 47 | +### 2. Build Artifacts |
| 48 | +```bash |
| 49 | +./gradlew clean build publishToMavenLocal -x test |
| 50 | +``` |
| 51 | + |
| 52 | +### 3. Full Release Workflow |
| 53 | +```bash |
| 54 | +# Dry run (recommended first) |
| 55 | +./gradlew jreleaserConfig |
| 56 | +./gradlew jreleaserFullReleaseDryRun |
| 57 | +
|
| 58 | +# Perform actual release |
| 59 | +./gradlew jreleaserFullRelease |
| 60 | +``` |
| 61 | + |
| 62 | +### 4. Manual Step-by-Step Release |
| 63 | +If you prefer to control each step: |
| 64 | + |
| 65 | +```bash |
| 66 | +# 1. Build and sign artifacts |
| 67 | +./gradlew clean build publishToMavenLocal -Psign -PsigningKey="$JRELEASER_GPG_SECRET_KEY" -PsigningPassword="$JRELEASER_GPG_PASSPHRASE" |
| 68 | +
|
| 69 | +# 2. Copy artifacts to staging directory |
| 70 | +./gradlew :java-snapshot-testing-core:publishToMavenLocal |
| 71 | +./gradlew :java-snapshot-testing-junit4:publishToMavenLocal |
| 72 | +./gradlew :java-snapshot-testing-junit5:publishToMavenLocal |
| 73 | +./gradlew :java-snapshot-testing-plugin-jackson:publishToMavenLocal |
| 74 | +./gradlew :java-snapshot-testing-plugin-jackson3:publishToMavenLocal |
| 75 | +./gradlew :java-snapshot-testing-spock:publishToMavenLocal |
| 76 | +
|
| 77 | +# 3. Upload to Maven Central Portal |
| 78 | +./gradlew jreleaserPublish |
| 79 | +``` |
| 80 | + |
| 81 | +## JReleaser Configuration |
| 82 | + |
| 83 | +The main configuration is in `jreleaser.yml`: |
| 84 | + |
| 85 | +- **project**: Project metadata (name, description, URL, etc.) |
| 86 | +- **signing**: GPG signing configuration |
| 87 | +- **deploy.maven.mavenCentral**: Maven Central Portal API settings |
| 88 | + - `url`: Portal API endpoint |
| 89 | + - `closeRepository`: Auto-close staging repository |
| 90 | + - `releaseRepository`: Auto-release after publishing |
| 91 | + |
| 92 | +## Environment Variables Reference |
| 93 | + |
| 94 | +| Variable | Description | |
| 95 | +|----------|-------------| |
| 96 | +| `JRELEASER_MAVENCENTRAL_USERNAME` | Maven Central Portal API username | |
| 97 | +| `JRELEASER_MAVENCENTRAL_PASSWORD` | Maven Central Portal API password | |
| 98 | +| `JRELEASER_GPG_SECRET_KEY` | Base64-encoded GPG secret key | |
| 99 | +| `JRELEASER_GPG_SECRET_KEY_FILE` | Path to GPG secret key file | |
| 100 | +| `JRELEASER_GPG_PASSPHRASE` | GPG key passphrase | |
| 101 | +| `JRELEASER_GITHUB_TOKEN` | GitHub token for creating releases | |
| 102 | +| `JRELEASER_DRY_RUN` | Set to `true` to perform dry run | |
| 103 | + |
| 104 | +## Useful JReleaser Tasks |
| 105 | + |
| 106 | +```bash |
| 107 | +# Show current configuration |
| 108 | +./gradlew jreleaserConfig |
| 109 | +
|
| 110 | +# Validate configuration |
| 111 | +./gradlew jreleaserValidate |
| 112 | +
|
| 113 | +# Full release (dry run) |
| 114 | +./gradlew jreleaserFullReleaseDryRun |
| 115 | +
|
| 116 | +# Full release (execute) |
| 117 | +./gradlew jreleaserFullRelease |
| 118 | +
|
| 119 | +# Just publish to Maven Central |
| 120 | +./gradlew jreleaserPublish |
| 121 | +
|
| 122 | +# Create GitHub release |
| 123 | +./gradlew jreleaserRelease |
| 124 | +
|
| 125 | +# Generate changelogs |
| 126 | +./gradlew jreleaserChangelog |
| 127 | +``` |
| 128 | + |
| 129 | +## Troubleshooting |
| 130 | + |
| 131 | +### Publication Fails |
| 132 | +- Ensure version in `gradle.properties` is not a SNAPSHOT |
| 133 | +- Verify Maven Central credentials are correct |
| 134 | +- Check that artifacts are properly signed |
| 135 | + |
| 136 | +### GPG Signing Issues |
| 137 | +- Verify GPG secret key is correctly base64 encoded |
| 138 | +- Ensure passphrase is correct |
| 139 | +- Test GPG locally: `gpg --list-secret-keys` |
| 140 | + |
| 141 | +### Maven Central Portal Issues |
| 142 | +- Login to https://central.sonatype.com and verify credentials |
| 143 | +- Check portal API documentation: https://central.sonatype.com/publishing/publish-maven/ |
| 144 | + |
| 145 | +## Migration from Previous Setup |
| 146 | + |
| 147 | +The previous setup used: |
| 148 | +- `net.researchgate.release` for version management |
| 149 | +- Direct OSSRH/Sonatype publishing |
| 150 | +- Manual staging repository management with `nexus-staging` |
| 151 | + |
| 152 | +The new JReleaser setup: |
| 153 | +- Still supports version management (can integrate with `net.researchgate.release`) |
| 154 | +- Automates the entire publish-to-Maven-Central flow |
| 155 | +- Uses the modern Portal Publisher API |
| 156 | +- Simplifies artifact signing and deployment |
| 157 | + |
| 158 | +## Additional Resources |
| 159 | + |
| 160 | +- [JReleaser Documentation](https://jreleaser.org/) |
| 161 | +- [Maven Central Portal Publisher API](https://central.sonatype.org/publishing/publish-maven/) |
| 162 | +- [JReleaser Gradle Plugin](https://jreleaser.org/guide/latest/reference/gradle.html) |
| 163 | +- [Maven Central Requirements](https://central.sonatype.org/publish/requirements/) |
0 commit comments