Skip to content

Commit e7012f5

Browse files
committed
fmt
1 parent 21bedeb commit e7012f5

1 file changed

Lines changed: 38 additions & 11 deletions

File tree

PUBLISHING.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@ This document describes how to publish the Permit.io Java SDK to Maven Central a
55
## Overview
66

77
The SDK is published to two repositories:
8+
89
- **Maven Central** - Primary distribution for public consumption
910
- **GitHub Packages** - Secondary distribution for GitHub-based workflows
1011

1112
## Prerequisites
1213

1314
### Maven Central Portal Account
15+
1416
1. Create an account at [central.sonatype.com](https://central.sonatype.com)
1517
2. Verify ownership of the `io.permit` namespace
1618
3. Generate a User Token: Account → Generate User Token
1719

1820
### GPG Signing Key
21+
1922
Maven Central requires all artifacts to be signed with GPG:
23+
2024
```bash
2125
# Generate a key (if you don't have one)
2226
gpg --full-generate-key
@@ -29,48 +33,58 @@ gpg --armor --export-secret-keys YOUR_KEY_ID | base64
2933

3034
Configure these secrets in your GitHub repository:
3135

32-
| Secret | Description |
33-
|--------|-------------|
36+
| Secret | Description |
37+
|--------------------------|------------------------------------|
3438
| `MAVEN_CENTRAL_USERNAME` | Username from Central Portal token |
3539
| `MAVEN_CENTRAL_PASSWORD` | Password from Central Portal token |
36-
| `GPG_SIGNING_KEY` | Base64-encoded GPG private key |
37-
| `GPG_SIGNING_PASSPHRASE` | Passphrase for the GPG key |
40+
| `GPG_SIGNING_KEY` | Base64-encoded GPG private key |
41+
| `GPG_SIGNING_PASSPHRASE` | Passphrase for the GPG key |
3842

3943
## Publishing Methods
4044

4145
### Automatic (CI/CD)
4246

4347
Publishing is triggered automatically when:
48+
4449
- A GitHub Release is created
4550
- The workflow is manually dispatched
4651

4752
The workflow (`.github/workflows/publish.yaml`) handles:
53+
4854
1. Javadoc verification
4955
2. Publishing to GitHub Packages
5056
3. Publishing to Maven Central
5157

5258
### Manual (Local)
5359

5460
#### Publish to Local Maven Repository
61+
5562
Test artifact generation without uploading:
63+
5664
```bash
5765
./gradlew publishToMavenLocal
5866
```
67+
5968
Artifacts are published to `~/.m2/repository/io/permit/permit-sdk-java/`
6069

6170
#### Publish to Maven Central (Staging Only)
71+
6272
Upload to Central Portal without releasing:
73+
6374
```bash
6475
./gradlew publishToMavenCentral \
6576
-PmavenCentralUsername=USERNAME \
6677
-PmavenCentralPassword=PASSWORD \
6778
-PsigningInMemoryKey="$(cat key.asc)" \
6879
-PsigningInMemoryKeyPassword=PASSPHRASE
6980
```
81+
7082
Review at [Central Portal Deployments](https://central.sonatype.com/publishing/deployments)
7183

7284
#### Publish and Release to Maven Central
85+
7386
Full publish with automatic release:
87+
7488
```bash
7589
./gradlew publishAndReleaseToMavenCentral \
7690
-PmavenCentralUsername=USERNAME \
@@ -80,6 +94,7 @@ Full publish with automatic release:
8094
```
8195

8296
#### Publish to GitHub Packages
97+
8398
```bash
8499
GITHUB_ACTOR=username GITHUB_TOKEN=token ./gradlew publish
85100
```
@@ -89,40 +104,49 @@ GITHUB_ACTOR=username GITHUB_TOKEN=token ./gradlew publish
89104
The `mavenPublishing` block in `build.gradle` supports different publishing modes:
90105

91106
### CENTRAL_PORTAL (Current)
107+
92108
```groovy
93109
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
94110
```
95-
Uses the new Maven Central Portal API at `central.sonatype.com`. This is the current recommended method as Sonatype has deprecated the legacy OSSRH system.
111+
112+
Uses the new Maven Central Portal API at `central.sonatype.com`. This is the current recommended method as Sonatype has
113+
deprecated the legacy OSSRH system.
96114

97115
### S01 (Legacy OSSRH)
116+
98117
```groovy
99118
publishToMavenCentral(SonatypeHost.S01)
100119
```
120+
101121
Uses the legacy Sonatype OSSRH at `s01.oss.sonatype.org`. This method is deprecated and may stop working.
102122

103123
### DEFAULT (Legacy OSSRH)
124+
104125
```groovy
105126
publishToMavenCentral(SonatypeHost.DEFAULT)
106127
```
128+
107129
Uses the original Sonatype OSSRH at `oss.sonatype.org`. This is for older projects and is deprecated.
108130

109131
## Gradle Tasks
110132

111-
| Task | Description |
112-
|------|-------------|
113-
| `publishToMavenLocal` | Publish to local Maven cache (~/.m2) |
114-
| `publishToMavenCentral` | Upload to Central Portal (staging) |
115-
| `publishAndReleaseToMavenCentral` | Upload and release to Maven Central |
116-
| `publish` | Publish to all configured repositories (GitHub Packages) |
133+
| Task | Description |
134+
|-----------------------------------|----------------------------------------------------------|
135+
| `publishToMavenLocal` | Publish to local Maven cache (~/.m2) |
136+
| `publishToMavenCentral` | Upload to Central Portal (staging) |
137+
| `publishAndReleaseToMavenCentral` | Upload and release to Maven Central |
138+
| `publish` | Publish to all configured repositories (GitHub Packages) |
117139

118140
## Versioning
119141

120142
Version is automatically determined by the `com.palantir.git-version` plugin based on git tags:
143+
121144
- Tagged commit: `2.2.0`
122145
- Commits after tag: `2.2.0-1-gabcdef`
123146
- Dirty working directory: `2.2.0-1-gabcdef.dirty`
124147

125148
To release a new version:
149+
126150
```bash
127151
git tag 2.3.0
128152
git push origin 2.3.0
@@ -131,14 +155,17 @@ git push origin 2.3.0
131155
## Troubleshooting
132156

133157
### 403 Forbidden
158+
134159
- Credentials may be invalid or expired
135160
- Regenerate token at Central Portal
136161

137162
### Signature Verification Failed
163+
138164
- GPG key may be malformed
139165
- Ensure key is base64 encoded without line breaks
140166

141167
### Version Already Exists
168+
142169
- Maven Central doesn't allow overwriting versions
143170
- Bump the version and try again
144171

0 commit comments

Comments
 (0)