Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Build with Gradle
run: ./gradlew build
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
name: Deploy SNAPSHOT
runs-on: ubuntu-latest
steps:
Expand All @@ -46,20 +46,5 @@ jobs:
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Jar
run: ./gradlew shadowJar
- name: Generate tag version
uses: anothrNick/github-tag-action@v1
id: tag_version_dry_run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DRY_RUN: true
- name: publish
env:
SNAPSHOT_VERSION: ${{ steps.tag_version_dry_run.outputs.tag }}-SNAPSHOT
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY_ASCII_ARMOR }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_KEY_PASSPHRASE }}
MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
run: ./gradlew publish -Pversion=$SNAPSHOT_VERSION -PossrhUsername=${MAVEN_CENTRAL_TOKEN_USERNAME} -PossrhPassword=${MAVEN_CENTRAL_TOKEN_PASSWORD} -Psign=true
- name: Build and publish SNAPSHOT to Maven Local
run: ./gradlew clean build publishToMavenLocal -x test
62 changes: 18 additions & 44 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,30 @@ on:

jobs:
release:
name: Release to Maven Central, Tag & Release
name: Release with JReleaser
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Generate tag version
uses: anothrNick/github-tag-action@v1
id: tag_version_dry_run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DRY_RUN: true
- name: Set up JDKs
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Jar
env:
RELEASE_VERSION: ${{ steps.tag_version_dry_run.outputs.tag }}
run: ./gradlew shadowJar -Pversion=$RELEASE_VERSION
- name: Publish to Maven Central
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY_ASCII_ARMOR }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_KEY_PASSPHRASE }}
MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
RELEASE_VERSION: ${{ steps.tag_version_dry_run.outputs.tag }}
run: ./gradlew -Pversion=$RELEASE_VERSION publish -PossrhUsername=${MAVEN_CENTRAL_TOKEN_USERNAME} -PossrhPassword=${MAVEN_CENTRAL_TOKEN_PASSWORD} -Psign=true
- name: Close & Release Staging Repository

- name: Build artifacts
run: ./gradlew clean build -x test

- name: Publish to Maven Central with JReleaser
env:
MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
run: ./gradlew closeAndReleaseRepository -PossrhUsername=${MAVEN_CENTRAL_TOKEN_USERNAME} -PossrhPassword=${MAVEN_CENTRAL_TOKEN_PASSWORD}
- name: Push new tag
uses: anothrNick/github-tag-action@v1
id: tag_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DRY_RUN: false
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Github Release
uses: softprops/action-gh-release@v1
with:
body: ${{steps.github_release.outputs.changelog}}
tag_name: ${{ steps.tag_version.outputs.tag }}
files: java-snapshot-testing-*/build/libs/*.jar
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY_ASCII_ARMOR }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew jreleaserFullRelease
64 changes: 27 additions & 37 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,53 +34,43 @@ Ensure you add `mavenLocal()` to your consuming project and the dependency veris
folder

# Uploading to maven central
see `.github/workflows/release.yml`

# Uploading to maven central (manually)
The project now uses [JReleaser](https://jreleaser.org/) to automate releases to Maven Central.

Gradle release plugin is not currently working so this is a manual process at the moment.
See [JRELEASER_SETUP.md](JRELEASER_SETUP.md) for complete setup and release instructions.

# Setup GPG on your machine
### Quick Release Steps

1. copy the GPG Private key into a file `private.key`
1. run
1. Ensure you have Maven Central Portal API credentials:
- `JRELEASER_MAVENCENTRAL_USERNAME`
- `JRELEASER_MAVENCENTRAL_PASSWORD`

```
gpg --import private.key
gpg -k
```
2. Setup GPG signing (see JRELEASER_SETUP.md)

## Preparing
3. Update version in `gradle.properties` (remove `-SNAPSHOT`)

1. Create a tag `X.X.X`
1. Update `gradle.properties` and remove `-SNAPSHOT` from the version number
1. Check this file into version control and push the branch to the remote
1. run
4. Run full release:
```bash
./gradlew jreleaserFullRelease
```

```
export SONAR_USERNAME=?
export SONAR_PASSWORD=?
export ORG_GRADLE_PROJECT_signingKey="$(cat private.key)"
export ORG_GRADLE_PROJECT_signingPassword=?

# I found shadowed classes are not included if you don't separate the gradle operations
./gradlew clean shadowJar
./gradlew publish -PossrhUsername=${SONAR_USERNAME} -PossrhPassword=${SONAR_PASSWORD} -Psign=true
Or use step-by-step approach:
```bash
./gradlew clean build publishToMavenLocal -Psign
./gradlew jreleaserPublish
```

## Releasing [Full Tutorial](https://central.sonatype.org/pages/ossrh-guide.html)
JReleaser will automatically:
- Sign all artifacts with GPG
- Publish to Maven Central via Portal API
- Close and release the staging repository
- Create a GitHub release

1. Login to SONAR (https://oss.sonatype.org)
1. Click 'Staging Repositories' and locate the 'iogithubcodedabble-dev' bundle
1. Review artifacts are correct in the 'Content' tab
1. Press the 'Close' and give a reason such as "Jack Matthews - Confirmed artifacts are OK"
1. Wait for about 1 min and press the 'Refresh button', if all sanity checks have passed the 'Release' button will be
visible
1. Press the 'Release' button and give a reason for releasing
1. Objects should be available in about 10 min (Longer for search.maven.org)
### Previous Manual Process (No Longer Needed)

## Cleanup
The old process involved:
1. Manual staging repository management via Sonatype UI
2. Direct OSSRH publishing
3. Manual close/release steps

1. Checkout master branch
1. Increment version number in `gradle.properties`
1. Create pull request for merge
All of this is now automated by JReleaser.
127 changes: 127 additions & 0 deletions JRELEASER_MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# JReleaser Migration Summary

This document summarizes the conversion from manual Maven Central publishing via OSSRH to automated publishing using JReleaser.

## Changes Made

### 1. **build.gradle**
- Added JReleaser Gradle plugin: `id 'org.jreleaser' version '1.13.1'`
- Applied jreleaser plugin to root project

### 2. **gradle/publishing.gradle**
- **Removed**: Direct Sonatype OSSRH repository configuration
- **Removed**: nexus-staging plugin configuration and usage
- **Added**: Local repository configuration (`build/repos/release`)
- **Updated**: Signing configuration to detect JReleaser environment variables
- `JRELEASER_GPG_SECRET_KEY`
- `JRELEASER_GPG_SECRET_KEY_FILE`
- `JRELEASER_GPG_PASSPHRASE`

### 3. **New File: jreleaser.yml**
Complete JReleaser configuration including:
- Project metadata (name, description, URL, license, authors)
- GPG signing configuration with verification
- Maven Central Portal Publisher API configuration
- Automatic repository closing and release

### 4. **New File: JRELEASER_SETUP.md**
Comprehensive guide covering:
- Prerequisites and credential setup
- Step-by-step release process
- Environment variable reference
- Troubleshooting tips
- JReleaser task reference

### 5. **CONTRIBUTING.md**
- Replaced old manual release instructions
- Added link to JRELEASER_SETUP.md
- Documented new quick release steps

## Key Improvements

| Aspect | Before | After |
|--------|--------|-------|
| **Repository Management** | Manual via Sonatype UI | Automated by JReleaser |
| **Staging** | Manual close/release steps | Auto close/release |
| **Publishing** | Direct OSSRH API | Maven Central Portal API |
| **GPG Signing** | Manual gradle parameters | Environment variables |
| **Release Workflow** | Multi-step manual process | Single `jreleaserFullRelease` command |
| **GitHub Releases** | Manual creation | Automated by JReleaser |

## Migration Path

### Old Workflow
```bash
# Manual staging
./gradlew publish -PossrhUsername=... -PossrhPassword=... -Psign=true

# Manual login to Sonatype UI
# - Locate staging repo
# - Close repo
# - Release repo
# - Wait for sync
```

### New Workflow
```bash
# Automated full release
./gradlew jreleaserFullRelease
```

## Backward Compatibility

- Old gradle properties can still be used if needed
- The `net.researchgate.release` plugin is retained for version management
- Manual publishing with `-PossrhUsername/-PossrhPassword` still works but not recommended

## Environment Setup for Releases

To perform releases, configure these environment variables:

```bash
export JRELEASER_MAVENCENTRAL_USERNAME="your-sonatype-token-username"
export JRELEASER_MAVENCENTRAL_PASSWORD="your-sonatype-token-password"
export JRELEASER_GPG_SECRET_KEY="base64-encoded-gpg-key"
export JRELEASER_GPG_PASSPHRASE="your-gpg-passphrase"
export JRELEASER_GITHUB_TOKEN="github-token-if-creating-releases" # optional
```

Or use GPG key file:
```bash
export JRELEASER_GPG_SECRET_KEY_FILE="/path/to/gpg/key.gpg"
```

## Testing Before Production Release

1. **Dry Run**:
```bash
./gradlew jreleaserFullReleaseDryRun
```

2. **Validate Config**:
```bash
./gradlew jreleaserValidate
```

3. **View Config**:
```bash
./gradlew jreleaserConfig
```

## Resources

- [JReleaser Official Documentation](https://jreleaser.org/)
- [JReleaser Gradle Plugin Guide](https://jreleaser.org/guide/latest/reference/gradle.html)
- [Maven Central Portal API](https://central.sonatype.org/publishing/publish-maven/)
- [JRELEASER_SETUP.md](./JRELEASER_SETUP.md) - Detailed setup guide

## Next Steps

1. Store Maven Central Portal API credentials securely (e.g., GitHub Secrets)
2. Optionally update CI/CD workflows to use jreleaser
3. Test with a dry-run release: `./gradlew jreleaserFullReleaseDryRun`
4. Perform first production release when ready

## Questions?

See [JRELEASER_SETUP.md](./JRELEASER_SETUP.md) for detailed troubleshooting and additional information.
Loading
Loading