Skip to content

Commit 35b20bd

Browse files
committed
Add maven publish task
1 parent 67f8f4c commit 35b20bd

File tree

3 files changed

+102
-4
lines changed

3 files changed

+102
-4
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@ jobs:
3434
${{ github.ref_name }} \
3535
build/libs/multiline-regex-datacapture-filter-${{ steps.get_version.outputs.VERSION }}.jar
3636
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Publish to Maven Central
39+
run: ./gradlew -PsigningKey=${SIGNING_KEY_B64} -PsigningPassword=${SIGNING_PASSWORD} -PsonatypeUsername=${SONATYPE_USERNAME} -PsonatypePassword=${SONATYPE_PASSWORD} publishToSonatype closeAndReleaseSonatypeStagingRepository
40+
env:
41+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
42+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
43+
SIGNING_KEY_B64: ${{ secrets.SIGNING_KEY_B64 }}
44+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

build.gradle

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@ plugins {
22
id 'groovy'
33
id 'java'
44
id 'pl.allegro.tech.build.axion-release' version '1.7.1'
5+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
56
}
67

7-
group 'com.rundeck.plugin'
8+
group 'org.rundeck.plugins'
9+
10+
ext.publishName = "Multiline Regex Datacapture Filter ${project.version}"
11+
ext.publishDescription = project.description ?: 'Multiline Regex Datacapture Filter Plugin'
12+
ext.githubSlug = 'rundeck-plugins/multiline-regex-datacapture-filter-plugin'
13+
ext.developers = [
14+
[id: 'gschueler', name: 'Greg Schueler', email: '[email protected]']
15+
]
816

917
ext.rundeckVersion='5.11.1-20250415'
1018
defaultTasks 'clean','build'
1119
ext.rundeckPluginVersion= '1.2'
12-
group 'com.rundeck.plugin'
20+
group 'org.rundeck.plugins'
1321

1422
scmVersion {
1523
ignoreUncommittedChanges = false
@@ -29,7 +37,11 @@ scmVersion {
2937
}
3038
project.version = scmVersion.version
3139

32-
sourceCompatibility = 11
40+
java {
41+
sourceCompatibility = JavaVersion.VERSION_11
42+
withJavadocJar()
43+
withSourcesJar()
44+
}
3345

3446

3547
/**
@@ -88,3 +100,12 @@ jar {
88100
}
89101
//set jar task to depend on copyToLib
90102
jar.dependsOn(copyToLib)
103+
104+
nexusPublishing {
105+
packageGroup = 'org.rundeck.plugins'
106+
repositories {
107+
sonatype()
108+
}
109+
}
110+
111+
apply from: "${rootDir}/gradle/publishing.gradle"

gradle/publishing.gradle

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* Define project extension values in the project gradle file before including this file:
3+
*
4+
* publishName = 'Name of Package'
5+
* publishDescription = 'description' (optional)
6+
* githubSlug = Github slug e.g. 'rundeck/rundeck-cli'
7+
* developers = [ [id:'id', name:'name', email: 'email' ] ] list of developers
8+
*
9+
* Define project properties to sign and publish when invoking publish task:
10+
*
11+
* ./gradlew \
12+
* -PsigningKey="base64 encoded gpg key" \
13+
* -PsigningPassword="password for key" \
14+
* -PsonatypeUsername="sonatype token user" \
15+
* -PsonatypePassword="sonatype token password" \
16+
* publishToSonatype closeAndReleaseSonatypeStagingRepository
17+
*/
18+
apply plugin: 'maven-publish'
19+
apply plugin: 'signing'
20+
21+
publishing {
22+
publications {
23+
"${project.name}"(MavenPublication) { publication ->
24+
from components.java
25+
26+
pom {
27+
name = publishName
28+
description = project.ext.hasProperty('publishDescription') ? project.ext.publishDescription :
29+
project.description ?: publishName
30+
url = "https://github.com/${githubSlug}"
31+
licenses {
32+
license {
33+
name = 'The Apache Software License, Version 2.0'
34+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
35+
distribution = 'repo'
36+
}
37+
}
38+
scm {
39+
url = "https://github.com/${githubSlug}"
40+
connection = "scm:git:[email protected]/${githubSlug}.git"
41+
developerConnection = "scm:git:[email protected]:${githubSlug}.git"
42+
}
43+
if (project.ext.developers) {
44+
developers {
45+
project.ext.developers.each { dev ->
46+
developer {
47+
id = dev.id
48+
name = dev.name
49+
email = dev.email
50+
}
51+
}
52+
}
53+
}
54+
}
55+
56+
}
57+
}
58+
}
59+
def base64Decode = { String prop ->
60+
project.findProperty(prop) ?
61+
new String(Base64.getDecoder().decode(project.findProperty(prop).toString())).trim() :
62+
null
63+
}
64+
65+
if (project.hasProperty('signingKey') && project.hasProperty('signingPassword')) {
66+
signing {
67+
useInMemoryPgpKeys(base64Decode("signingKey"), project.signingPassword)
68+
sign(publishing.publications)
69+
}
70+
}

0 commit comments

Comments
 (0)