Skip to content

Add maven publish task #10

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 1 commit into from
May 19, 2025
Merged
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
9 changes: 8 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ jobs:
${{ github.ref_name }} \
build/libs/multiline-regex-datacapture-filter-${{ steps.get_version.outputs.VERSION }}.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Maven Central
run: ./gradlew -PsigningKey=${SIGNING_KEY_B64} -PsigningPassword=${SIGNING_PASSWORD} -PsonatypeUsername=${SONATYPE_USERNAME} -PsonatypePassword=${SONATYPE_PASSWORD} publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SIGNING_KEY_B64: ${{ secrets.SIGNING_KEY_B64 }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
27 changes: 24 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ plugins {
id 'groovy'
id 'java'
id 'pl.allegro.tech.build.axion-release' version '1.7.1'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
}

group 'com.rundeck.plugin'
group 'org.rundeck.plugins'

ext.publishName = "Multiline Regex Datacapture Filter ${project.version}"
ext.publishDescription = project.description ?: 'Multiline Regex Datacapture Filter Plugin'
ext.githubSlug = 'rundeck-plugins/multiline-regex-datacapture-filter-plugin'
ext.developers = [
[id: 'gschueler', name: 'Greg Schueler', email: '[email protected]']
]

ext.rundeckVersion='5.11.1-20250415'
defaultTasks 'clean','build'
ext.rundeckPluginVersion= '1.2'
group 'com.rundeck.plugin'
group 'org.rundeck.plugins'

scmVersion {
ignoreUncommittedChanges = false
Expand All @@ -29,7 +37,11 @@ scmVersion {
}
project.version = scmVersion.version

sourceCompatibility = 11
java {
sourceCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}


/**
Expand Down Expand Up @@ -88,3 +100,12 @@ jar {
}
//set jar task to depend on copyToLib
jar.dependsOn(copyToLib)

nexusPublishing {
packageGroup = 'org.rundeck.plugins'
repositories {
sonatype()
}
}

apply from: "${rootDir}/gradle/publishing.gradle"
70 changes: 70 additions & 0 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Define project extension values in the project gradle file before including this file:
*
* publishName = 'Name of Package'
* publishDescription = 'description' (optional)
* githubSlug = Github slug e.g. 'rundeck/rundeck-cli'
* developers = [ [id:'id', name:'name', email: 'email' ] ] list of developers
*
* Define project properties to sign and publish when invoking publish task:
*
* ./gradlew \
* -PsigningKey="base64 encoded gpg key" \
* -PsigningPassword="password for key" \
* -PsonatypeUsername="sonatype token user" \
* -PsonatypePassword="sonatype token password" \
* publishToSonatype closeAndReleaseSonatypeStagingRepository
*/
apply plugin: 'maven-publish'
apply plugin: 'signing'

publishing {
publications {
"${project.name}"(MavenPublication) { publication ->
from components.java

pom {
name = publishName
description = project.ext.hasProperty('publishDescription') ? project.ext.publishDescription :
project.description ?: publishName
url = "https://github.com/${githubSlug}"
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
scm {
url = "https://github.com/${githubSlug}"
connection = "scm:git:[email protected]/${githubSlug}.git"
developerConnection = "scm:git:[email protected]:${githubSlug}.git"
}
if (project.ext.developers) {
developers {
project.ext.developers.each { dev ->
developer {
id = dev.id
name = dev.name
email = dev.email
}
}
}
}
}

}
}
}
def base64Decode = { String prop ->
project.findProperty(prop) ?
new String(Base64.getDecoder().decode(project.findProperty(prop).toString())).trim() :
null
}

if (project.hasProperty('signingKey') && project.hasProperty('signingPassword')) {
signing {
useInMemoryPgpKeys(base64Decode("signingKey"), project.signingPassword)
sign(publishing.publications)
}
}
Loading