Skip to content

Commit faaa2bd

Browse files
committed
add gradle catalog
publish to maven
1 parent c137257 commit faaa2bd

4 files changed

Lines changed: 156 additions & 52 deletions

File tree

.github/workflows/release.yml

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,45 @@
1-
name: Create Release
2-
31
on:
42
push:
3+
# Sequence of patterns matched against refs/tags
54
tags:
6-
- '*'
5+
- 'v[0-9]+.[0-9]+.[0-9]+' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+
name: Upload Release Asset
78

89
jobs:
9-
release:
10-
name: Create Release
10+
build:
11+
name: Upload Release Asset
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Checkout code
1415
uses: actions/checkout@v4
1516
with:
1617
fetch-depth: 0
1718

18-
- name: Set up JDK 11
19-
uses: actions/setup-java@v3
19+
- name: Set up JDK 11
20+
uses: actions/setup-java@v4
2021
with:
2122
java-version: '11'
22-
distribution: 'temurin'
23-
cache: gradle
24-
25-
- name: Cache Gradle and Assets
26-
uses: actions/cache@v3
27-
with:
28-
path: |
29-
~/.gradle/caches
30-
~/.gradle/wrapper
31-
.gradle
32-
build/assets
33-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '.gradle/dependency-locks/*') }}
34-
restore-keys: |
35-
${{ runner.os }}-gradle-
36-
37-
- name: Grant execute permission for gradlew
38-
run: chmod +x gradlew
39-
40-
- name: Build Release
41-
run: ./gradlew clean build --info
42-
23+
distribution: 'zulu'
24+
- name: Build with Gradle
25+
run: ./gradlew build
4326
- name: Get Release Version
4427
id: get_version
45-
run: |
46-
VERSION=$(./gradlew currentVersion -q -Prelease.quiet | tail -n 1)
47-
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
48-
echo "Detected version: ${VERSION}"
49-
28+
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
5029
- name: Create Release
5130
id: create_release
52-
uses: softprops/action-gh-release@v1
53-
with:
54-
name: Release ${{ steps.get_version.outputs.VERSION }}
55-
draft: false
56-
prerelease: false
57-
files: |
31+
run: |
32+
gh release create \
33+
--generate-notes \
34+
--title 'Release ${{ steps.get_version.outputs.VERSION }}' \
35+
${{ github.ref_name }} \
5836
build/libs/git-plugin-${{ steps.get_version.outputs.VERSION }}.jar
5937
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
- name: Publish to Maven Central
40+
run: ./gradlew -PsigningKey=${SIGNING_KEY_B64} -PsigningPassword=${SIGNING_PASSWORD} -PsonatypeUsername=${SONATYPE_USERNAME} -PsonatypePassword=${SONATYPE_PASSWORD} publishToSonatype closeAndReleaseSonatypeStagingRepository
41+
env:
42+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
43+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
44+
SIGNING_KEY_B64: ${{ secrets.SIGNING_KEY_B64 }}
45+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

build.gradle

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
plugins {
2-
id 'pl.allegro.tech.build.axion-release' version '1.16.1'
2+
alias(libs.plugins.axionRelease)
3+
alias(libs.plugins.nexusPublish)
4+
id 'java'
35
}
46

57
group 'com.rundeck'
68

79
ext.rundeckPluginVersion = '1.2'
10+
ext.publishName = "Git Plugin ${project.version}"
11+
ext.githubSlug = 'rundeck-plugins/git-plugin'
812
ext.pluginClassNames='com.rundeck.plugin.GitResourceModelFactory,com.rundeck.plugin.GitCloneWorkflowStep,com.rundeck.plugin.GitPushWorkflowStep,com.rundeck.plugin.GitCommitWorkflowStep,com.rundeck.plugin.GitAddWorkflowStep'
913
ext.pluginName = 'Git Plugin'
1014
ext.pluginDescription = 'This is a git plugin (based on Jgit) which contain a Resource model and worflow steps'
1115

16+
java {
17+
sourceCompatibility = JavaVersion.VERSION_11
18+
targetCompatibility = JavaVersion.VERSION_11
19+
}
20+
1221
scmVersion {
1322
ignoreUncommittedChanges = true
1423
tag {
@@ -35,27 +44,23 @@ configurations {
3544

3645

3746
dependencies {
38-
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
39-
testImplementation group: 'junit', name: 'junit', version: '4.13.1'
47+
// Use catalog aliases for dependencies
48+
implementation(libs.groovyAll)
49+
implementation(libs.rundeckCore)
50+
implementation(libs.slf4jApi)
4051

41-
implementation group: 'org.rundeck', name: 'rundeck-core', version: '5.1.0-rc2-20240124'
42-
implementation 'org.slf4j:slf4j-api:1.7.30'
43-
44-
pluginLibs('org.eclipse.jgit:org.eclipse.jgit:6.6.1.202309021850-r') {
52+
pluginLibs(libs.jgit) {
4553
exclude module: 'slf4j-api'
4654
exclude module: 'jsch'
4755
exclude module: 'commons-logging'
4856
}
4957

50-
pluginLibs ("org.eclipse.jgit:org.eclipse.jgit.ssh.jsch:5.13.2.202306221912-r"){
58+
pluginLibs(libs.jgitSsh) {
5159
exclude module: 'slf4j-api'
5260
exclude group: 'org.bouncycastle'
5361
}
5462

55-
testImplementation "org.codehaus.groovy:groovy-all:3.0.9"
56-
testImplementation "org.spockframework:spock-core:2.0-groovy-3.0"
57-
testImplementation "cglib:cglib-nodep:2.2.2"
58-
testImplementation 'org.objenesis:objenesis:1.4'
63+
testImplementation libs.bundles.testLibs
5964
}
6065

6166

@@ -84,3 +89,15 @@ jar {
8489
}
8590
dependsOn(copyToLib)
8691
}
92+
93+
nexusPublishing {
94+
packageGroup = 'org.rundeck-plugins'
95+
repositories {
96+
sonatype{
97+
stagingProfileId = '67d196ce5bae'
98+
}
99+
}
100+
}
101+
102+
103+
apply from: "${rootDir}/gradle/publishing.gradle"

gradle/libs.versions.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[versions]
2+
# Plugins
3+
axionRelease = "1.18.14"
4+
# Libraries
5+
groovy = "3.0.22"
6+
junit = "4.13.2"
7+
rundeckCore = "5.10.0-20250312"
8+
slf4j = "1.7.36"
9+
jgit = "6.6.1.202309021850-r"
10+
jgitSsh = "5.13.3.202401111512-r"
11+
spock = "2.0-groovy-3.0"
12+
cglib = "3.3.0"
13+
objenesis = "1.4"
14+
nexusPublish = "1.3.0"
15+
16+
[libraries]
17+
groovyAll = { group = "org.codehaus.groovy", name = "groovy-all", version.ref = "groovy" }
18+
junit = { group = "junit", name = "junit", version.ref = "junit" }
19+
rundeckCore = { group = "org.rundeck", name = "rundeck-core", version.ref = "rundeckCore" }
20+
slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
21+
jgit = { group = "org.eclipse.jgit", name = "org.eclipse.jgit", version.ref = "jgit" }
22+
jgitSsh = { group = "org.eclipse.jgit", name = "org.eclipse.jgit.ssh.jsch", version.ref = "jgitSsh" }
23+
spockCore = { group = "org.spockframework", name = "spock-core", version.ref = "spock" }
24+
cglibNodep = { group = "cglib", name = "cglib-nodep", version.ref = "cglib" }
25+
objenesis = { group = "org.objenesis", name = "objenesis", version.ref = "objenesis" }
26+
27+
[bundles]
28+
testLibs = ["junit", "groovyAll", "spockCore", "cglibNodep", "objenesis"]
29+
30+
[plugins]
31+
axionRelease = { id = "pl.allegro.tech.build.axion-release", version.ref = "axionRelease" }
32+
nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublish" }

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:git@github.com/${githubSlug}.git"
41+
developerConnection = "scm:git:git@github.com:${githubSlug}.git"
42+
}
43+
if (project.ext.hasProperty('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)