-
Notifications
You must be signed in to change notification settings - Fork 17
Publishing update #74
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cea6162
Migrated publishing to suppoer central sonatype repo
ikarenkov 3a1261e
Add publishing instructions into PUBLISHING.md
ikarenkov 49d60e5
Bumped version to 0.11.0-rc2
ikarenkov 99ccf56
Merge branch 'releases/0.11.0' into publishing-update
ikarenkov 8f7011d
Formated Gradle command as single line
ikarenkov 57a8d35
Fixed missing nexus publish plugin declaration
ikarenkov db9ddde
Fix detekt
ikarenkov 4f939de
Suppressed agp update issue
ikarenkov 33b5e1f
Roll back kotlin version
ikarenkov 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ build/ | |
|
|
||
| # Properties | ||
| local.properties | ||
| settings.xml | ||
|
|
||
| # Idea | ||
| .idea/ | ||
|
|
||
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,141 @@ | ||
| # Publishing to Maven Central | ||
|
|
||
| This guide is for library maintainers who need to publish new versions of Modo to Maven Central. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### 1. Credentials Setup | ||
|
|
||
| Create `local.properties` file in the project root (gitignored): | ||
|
|
||
| ```properties | ||
| sonatypeUsername=your-central-portal-username | ||
| sonatypePassword=your-central-portal-password | ||
| signing.keyId=your-gpg-key-id | ||
| signing.password=your-gpg-key-password | ||
| signing.secretKeyRingFile=path/to/secring.gpg | ||
| ``` | ||
|
|
||
| **Where to get credentials:** | ||
| - **Sonatype credentials**: Register at [Maven Central Portal](https://central.sonatype.com) and generate a user token | ||
| - **GPG signing key**: Generate using `gpg --gen-key` and export with `gpg --export-secret-keys` | ||
|
|
||
| ### 2. Update Version | ||
|
|
||
| Update the version in `gradle/libs.versions.toml`: | ||
| ```toml | ||
| [versions] | ||
| modo = "x.y.z" # Update this | ||
| ``` | ||
|
|
||
| ## Publishing Workflows | ||
|
|
||
| ### Option 1: Manual Release (Recommended) | ||
|
|
||
| This workflow publishes to a staging repository and validates artifacts, but requires manual approval before releasing to Maven Central. | ||
|
|
||
| ```bash | ||
| ./gradlew clean modo-compose:bundleReleaseAar publishAllPublicationsToSonatypeRepository closeSonatypeStagingRepository | ||
| ``` | ||
|
|
||
| **What happens:** | ||
| 1. ✅ Artifacts are built (AAR, sources, javadoc) | ||
| 2. ✅ Artifacts are signed with GPG | ||
| 3. ✅ Uploaded to staging repository | ||
| 4. ✅ Repository is closed and validated | ||
| 5. ⏸️ **Waits for manual approval** | ||
|
|
||
| **Next steps:** | ||
| 1. Go to https://central.sonatype.com/publishing | ||
| 2. Find your deployment (should show as "VALIDATED") | ||
| 3. Review the artifacts | ||
| 4. Click **"Publish"** to release to Maven Central | ||
| 5. Or click **"Drop"** to discard if something is wrong | ||
|
|
||
| **Why this is recommended:** | ||
| - ✅ Review artifacts before public release | ||
| - ✅ Can drop/fix if errors are found | ||
| - ✅ Safer for production releases | ||
| - ⚠️ Remember: Once published, versions are **immutable** | ||
|
|
||
| ### Option 2: Automatic Release | ||
|
|
||
| This workflow automatically publishes to Maven Central after validation, with no manual review step. | ||
|
|
||
| ```bash | ||
| ./gradlew clean modo-compose:bundleReleaseAar \ | ||
| publishAllPublicationsToSonatypeRepository \ | ||
| closeAndReleaseSonatypeStagingRepository | ||
| ``` | ||
|
|
||
| **What happens:** | ||
| 1. ✅ Artifacts are built, signed, and uploaded | ||
| 2. ✅ Repository is closed and validated | ||
| 3. ✅ **Automatically released to Maven Central** | ||
| 4. ⏳ Artifacts appear on Maven Central within 10-30 minutes | ||
|
|
||
| **Use with caution:** | ||
| - ⚠️ No manual review - artifacts become public immediately | ||
| - ⚠️ Better for hotfixes or when you're very confident | ||
| - ⚠️ Can't undo once released | ||
|
|
||
| ## Important Notes | ||
|
|
||
| ### Gradle Session State | ||
|
|
||
| ⚠️ **All publishing tasks must run in a single command.** Running them separately will fail: | ||
|
|
||
| ```bash | ||
| # ❌ This will fail | ||
| ./gradlew publishAllPublicationsToSonatypeRepository | ||
| ./gradlew closeSonatypeStagingRepository # Error: No staging repository found | ||
|
|
||
| # ✅ This works | ||
| ./gradlew publishAllPublicationsToSonatypeRepository closeSonatypeStagingRepository | ||
| ``` | ||
|
|
||
| **Why?** The staging repository ID is stored in Gradle's task state, which only exists during one session. See the note in the project explaining this behavior. | ||
|
|
||
| ### Version Immutability | ||
|
|
||
| Once a version is published to Maven Central: | ||
| - ❌ **Cannot be changed** | ||
| - ❌ **Cannot be deleted** | ||
| - ❌ **Cannot be republished** | ||
|
|
||
| If you publish a broken version, you must release a new version with a fix. | ||
|
|
||
| ### Timing | ||
|
|
||
| - **Validation**: Immediate (during close task) | ||
| - **Publication to Maven Central**: 10-30 minutes after release | ||
| - **Maven Central search**: May take up to 2 hours to index | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### "Component already exists" Error | ||
|
|
||
| You're trying to republish an existing version. Solution: | ||
| 1. Bump the version in `gradle/libs.versions.toml` | ||
| 2. Or drop the deployment from https://central.sonatype.com/publishing (if not yet published) | ||
|
|
||
| ### "401 Unauthorized" Error | ||
|
|
||
| Your credentials are invalid or from the old OSSRH system. Solution: | ||
| 1. Verify you're using credentials from https://central.sonatype.com (not oss.sonatype.org) | ||
| 2. Regenerate user token if needed | ||
| 3. Check `local.properties` has correct `sonatypeUsername` and `sonatypePassword` | ||
|
|
||
| ### "No staging repository found" Error | ||
|
|
||
| You ran tasks in separate Gradle invocations. Solution: | ||
| - Run all tasks in a single command (see "Gradle Session State" above) | ||
|
|
||
| ## Architecture Notes | ||
|
|
||
| This project uses: | ||
| - **`maven-publish` plugin**: Creates and signs artifacts (configured in `PublishingPlugin.kt`) | ||
| - **`gradle-nexus/publish-plugin`**: Manages Nexus staging workflow (configured in root `build.gradle.kts`) | ||
| - **OSSRH Staging API compatibility endpoint**: Bridges old Gradle plugins with new Central Portal | ||
|
|
||
| The migration from OSSRH to Central Portal is complete, using the compatibility endpoint to maintain existing workflow. |
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
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.
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.