-
Notifications
You must be signed in to change notification settings - Fork 5
Migrate to new Maven Central Portal for publishing #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zeevmoney
merged 19 commits into
master
from
zeev/per-13671-migrate-java-sdk-publishing-to-new-maven-central-portal
Jan 4, 2026
+278
−168
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1fbc37f
Migrate to new Maven Central Portal for publishing
zeevmoney dd8ddc3
Add documentation for Maven Central Portal configuration
zeevmoney bd2806c
wip
zeevmoney 203e542
Migrate to new Maven Central Portal for publishing
zeevmoney 756d441
wip
zeevmoney 21bedeb
Add publishing documentation
zeevmoney e7012f5
fmt
zeevmoney 06b48f9
Fix Gradle 8.x task dependency and duplicate artifact issues
zeevmoney 7126c2f
fmt
zeevmoney 8fa704f
Add detailed GPG key generation instructions to PUBLISHING.md
zeevmoney eaa3aa6
wip
zeevmoney 3c1d181
Remove legacy OSSRH publishing references
zeevmoney 5f65653
Update README with version range and latest javadoc links
zeevmoney 3495d4d
Update PUBLISHING.md
zeevmoney d4a0755
Update PUBLISHING.md
zeevmoney d2787f6
wip
zeevmoney 8b8231c
wip
zeevmoney 4cd0db5
Use NEXUS_TOKEN secrets for Maven Central publishing
zeevmoney 309c591
wip
zeevmoney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ build | |
| # Ignore stg schemas | ||
| stg-schemas/ | ||
| bin | ||
| /key.asc | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| # Publishing Guide | ||
|
|
||
| This document describes how to publish the Permit.io Java SDK to Maven Central and GitHub Packages. | ||
|
|
||
| ## Overview | ||
|
|
||
| The SDK is published to two repositories: | ||
|
|
||
| - **Maven Central** - Primary distribution for public consumption | ||
| - **GitHub Packages** - Secondary distribution for GitHub-based workflows | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Maven Central Portal Account | ||
|
|
||
| 1. Create an account at [central.sonatype.com](https://central.sonatype.com) | ||
| 2. Verify ownership of the `io.permit` namespace | ||
| 3. Generate a User Token: Account → Generate User Token | ||
|
|
||
| ### GPG Signing Key | ||
|
|
||
| Maven Central requires all artifacts to be signed with GPG. | ||
| [For more info see here.](https://central.sonatype.org/publish/requirements/gpg/) | ||
|
|
||
| #### Generate a new key (if you don't have one) | ||
|
|
||
| ```bash | ||
| gpg --full-generate-key | ||
| ``` | ||
|
|
||
| When prompted: | ||
|
|
||
| 1. **Key type**: Select `1` (RSA and RSA) | ||
| 2. **Key size**: Enter `4096` | ||
| 3. **Expiration**: Enter `0` (doesn't expire) or set a reasonable expiration | ||
| 4. **Name and email**: Use the same email as your Maven Central account | ||
| 5. **Passphrase**: Set a strong passphrase (this is your `signingInMemoryKeyPassword`) | ||
|
|
||
| #### List your keys | ||
|
|
||
| ```bash | ||
| gpg --list-secret-keys --keyid-format LONG | ||
| ``` | ||
|
|
||
| #### Export the private key | ||
|
|
||
| For local use: | ||
|
|
||
| ```bash | ||
| gpg --armor --export-secret-keys YOUR_KEY_ID > key.asc | ||
| ``` | ||
|
|
||
| For CI/CD (base64 encoded): | ||
|
|
||
| ```bash | ||
| gpg --armor --export-secret-keys YOUR_KEY_ID | base64 | ||
| ``` | ||
|
|
||
| #### Publish your public key (required for Maven Central verification) | ||
|
|
||
| ```bash | ||
| gpg --keyserver keyserver.ubuntu.com --send-keys YOUR_KEY_ID | ||
| # Note: in case you are getting "no route to host" error, ping this server and use the IP. | ||
| ``` | ||
|
|
||
| ## GitHub Secrets | ||
|
|
||
| Configure these secrets in your GitHub repository: | ||
|
|
||
| | Secret | Description | | ||
| |--------------------------|--------------------------------------------------------| | ||
| | `MAVEN_CENTRAL_USERNAME` | Username from Central Portal TOKEN (not the user) | | ||
| | `MAVEN_CENTRAL_PASSWORD` | Password from Central Portal TOKEN (not user password) | | ||
| | `GPG_SIGNING_KEY` | Base64-encoded GPG private key | | ||
| | `GPG_SIGNING_PASSPHRASE` | Passphrase for the GPG key | | ||
|
|
||
| ## Publishing Methods | ||
|
|
||
| ### Automatic (CI/CD) | ||
|
|
||
| Publishing is triggered automatically when: | ||
|
|
||
| - A GitHub Release is created | ||
| - The workflow is manually dispatched | ||
|
|
||
| The workflow (`.github/workflows/publish.yaml`) handles: | ||
|
|
||
| 1. Javadoc verification | ||
| 2. Publishing to GitHub Packages | ||
| 3. Publishing to Maven Central | ||
|
|
||
| ### Manual (Local) | ||
|
|
||
| #### Publish to Local Maven Repository | ||
|
|
||
| Test artifact generation without uploading: | ||
|
|
||
| ```bash | ||
| ./gradlew publishToMavenLocal -PskipSigning | ||
| ``` | ||
|
|
||
| Artifacts are published to `~/.m2/repository/io/permit/permit-sdk-java/` | ||
|
|
||
| Note: Use `-PskipSigning` for local testing without GPG keys. This flag is not available for Maven Central publishing ( | ||
| signing is required). | ||
|
zeevmoney marked this conversation as resolved.
Outdated
|
||
|
|
||
| #### Publish to Maven Central (Staging Only) | ||
|
|
||
| Upload to Central Portal without releasing: | ||
|
|
||
| ```bash | ||
| ./gradlew publishToMavenCentral \ | ||
| -PmavenCentralUsername=TOKEN_USERNAME \ | ||
| -PmavenCentralPassword=TOKEN_PASSWORD \ | ||
| -PsigningInMemoryKey="$(cat key.asc)" \ | ||
| -PsigningInMemoryKeyPassword=KEY_PASSPHRASE | ||
| ``` | ||
|
|
||
| Review at [Central Portal Deployments](https://central.sonatype.com/publishing/deployments) | ||
|
|
||
| #### Publish and Release to Maven Central | ||
|
|
||
| Full publish with automatic release: | ||
|
|
||
| ```bash | ||
| ./gradlew publishAndReleaseToMavenCentral \ | ||
| -PmavenCentralUsername=TOKEN_USERNAME \ | ||
| -PmavenCentralPassword=TOKEN_PASSWORD \ | ||
| -PsigningInMemoryKey="$(cat key.asc)" \ | ||
| -PsigningInMemoryKeyPassword=KEY_PASSPHRASE | ||
| ``` | ||
|
|
||
| #### Publish to GitHub Packages | ||
|
|
||
| ```bash | ||
| GITHUB_ACTOR=username GITHUB_TOKEN=token ./gradlew publish | ||
| ``` | ||
|
|
||
| ## Gradle Tasks | ||
|
|
||
| | Task | Description | | ||
| |-----------------------------------|----------------------------------------------------------| | ||
| | `publishToMavenLocal` | Publish to local Maven cache (~/.m2) | | ||
| | `publishToMavenCentral` | Upload to Central Portal (staging) | | ||
| | `publishAndReleaseToMavenCentral` | Upload and release to Maven Central | | ||
| | `publish` | Publish to all configured repositories (GitHub Packages) | | ||
|
|
||
| ## Versioning | ||
|
|
||
| Version is automatically determined by the `com.palantir.git-version` plugin based on git tags: | ||
|
|
||
| - Tagged commit: `2.2.0` | ||
| - Commits after tag: `2.2.0-1-gabcdef` | ||
| - Dirty working directory: `2.2.0-1-gabcdef.dirty` | ||
|
|
||
| To release a new version: | ||
|
|
||
| ```bash | ||
| git tag 2.3.0 | ||
| git push origin 2.3.0 | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### 403 Forbidden | ||
|
|
||
| - Credentials may be invalid or expired | ||
| - Regenerate token at Central Portal | ||
|
|
||
| ### Signature Verification Failed | ||
|
|
||
| - GPG key may be malformed | ||
| - Ensure key is base64 encoded without line breaks | ||
|
|
||
| ### Version Already Exists | ||
|
|
||
| - Maven Central doesn't allow overwriting versions | ||
| - Bump the version and try again | ||
|
|
||
| ## References | ||
|
|
||
| - [Maven Central Portal](https://central.sonatype.com) | ||
| - [vanniktech/gradle-maven-publish-plugin](https://vanniktech.github.io/gradle-maven-publish-plugin/central/) | ||
| - [Sonatype Publishing Guide](https://central.sonatype.org/publish/publish-portal-gradle/) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.