-
Notifications
You must be signed in to change notification settings - Fork 10
Publish to Sonatype Maven Central #31
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||||
| /** | ||||||
| * Shared publishing script for Maven Central (Sonatype). | ||||||
| * Applied from plugin-build.gradle after the mavenZip publication is defined. | ||||||
| * | ||||||
| * Expects project ext: publishName, publishDescription, githubSlug, developers | ||||||
| * (defaults set in plugin-build.gradle; subprojects may override in build.gradle). | ||||||
| * | ||||||
| * To publish: | ||||||
| * ./gradlew -PsigningKey="<base64 GPG key>" -PsigningPassword="..." \ | ||||||
| * -PsonatypeUsername="..." -PsonatypePassword="..." \ | ||||||
| * publishToSonatype closeAndReleaseSonatypeStagingRepository | ||||||
| */ | ||||||
|
|
||||||
| publishing.publications.mavenZip.pom { | ||||||
| name = publishName | ||||||
| description = project.ext.hasProperty('publishDescription') ? publishDescription : publishName | ||||||
|
||||||
| description = project.ext.hasProperty('publishDescription') ? publishDescription : publishName | |
| description = publishDescription |
Copilot
AI
Feb 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Apache License URL uses HTTP instead of HTTPS. Maven Central and modern best practices recommend using HTTPS URLs for all external references. The URL should be 'https://www.apache.org/licenses/LICENSE-2.0.txt' instead of 'http://www.apache.org/licenses/LICENSE-2.0.txt'.
| url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | |
| url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' |
Copilot
AI
Feb 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signing configuration has a potential security issue. The base64Decode function decodes the signingKey but doesn't validate it. If the signingKey property contains invalid base64 data, this will throw an IllegalArgumentException at runtime, which could expose the partial key data in error logs.
Consider adding try-catch error handling around the base64 decode operation to fail gracefully with a clearer error message that doesn't risk exposing sensitive data.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -57,14 +57,23 @@ pluginZip.doFirst { | |||||||||
|
|
||||||||||
| apply plugin: 'maven-publish' | ||||||||||
|
|
||||||||||
| // POM metadata defaults for Maven Central (subprojects may override in build.gradle) | ||||||||||
| ext.publishName = project.ext.hasProperty('publishName') ? project.ext.publishName : project.ext.archivesBaseName | ||||||||||
| ext.publishDescription = project.ext.hasProperty('publishDescription') ? project.ext.publishDescription : project.ext.pluginDescription | ||||||||||
| ext.githubSlug = project.ext.hasProperty('githubSlug') ? project.ext.githubSlug : 'rundeck-plugins/nixy-step-plugins' | ||||||||||
| ext.developers = project.ext.hasProperty('developers') ? project.ext.developers : [[id: 'gschueler', name: 'Greg Schueler', email: 'greg@rundeck.com']] | ||||||||||
|
|
||||||||||
| publishing { | ||||||||||
| publications { | ||||||||||
| mavenZip(MavenPublication) { | ||||||||||
|
||||||||||
| mavenZip(MavenPublication) { | |
| mavenZip(MavenPublication) { | |
| groupId = project.group | |
| artifactId = project.ext.archivesBaseName |
Copilot
AI
Feb 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a version conflict between the subproject version and the Maven publication version. The subprojects (e.g., command/build.gradle line 9) set project.version = 'v' + scmVersion.version (with 'v' prefix), but the mavenZip publication uses version = rootProject.version.toString() which comes from the root build.gradle that sets project.version = scmVersion.version (without 'v' prefix).
This creates an inconsistency where the plugin zip file will be named with the 'v' prefix (e.g., command-v1.0.0.zip) but the Maven artifact will be published with version 1.0.0 (no 'v' prefix). While this may be intentional for Maven coordinates (which shouldn't have a 'v' prefix), the inconsistency could cause confusion.
Consider either:
- Documenting this intentional difference
- Updating the subproject version logic to use rootProject.version directly
- Ensuring the archiveVersion in pluginZip task also uses rootProject.version for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if condition syntax is incorrect. In GitHub Actions, the secrets context cannot be accessed directly within the
ifexpression like this. The conditionsecrets.SONATYPE_USERNAME != ''will always evaluate to false because secrets are not available in the if context.To conditionally run this step based on whether secrets are set, you should either:
The recommended approach is to simply remove the if condition, as the Gradle task will fail with a clear error if the required properties are missing.