Skip to content

Commit 63d657a

Browse files
committed
Modernize build configuration and update GitHub workflows
- Added version catalog with libs.versions.toml - Updated build.gradle to use latest plugins - Added Java 11 compatibility - Added publishing.gradle for Maven Central publishing - Updated GitHub workflows for building and releasing - Use org.rundeck.plugins as Maven groupId
1 parent 261dd94 commit 63d657a

File tree

6 files changed

+190
-78
lines changed

6 files changed

+190
-78
lines changed

.github/workflows/gradle.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,28 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
1414
- name: Get Fetch Tags
1515
run: git -c protocol.version=2 fetch --tags --progress --no-recurse-submodules origin
1616
if: "!contains(github.ref, 'refs/tags')"
17-
- name: Set up JDK 1.8
18-
uses: actions/setup-java@v1
17+
- name: Set up JDK 11
18+
uses: actions/setup-java@v4
1919
with:
20-
java-version: 1.8
20+
java-version: '11'
21+
distribution: 'zulu'
2122
- name: Grant execute permission for gradlew
2223
run: chmod +x gradlew
2324
- name: Build with Gradle
2425
run: ./gradlew build
2526
- name: Get Release Version
2627
id: get_version
27-
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo ::set-output name=VERSION::$VERSION
28-
- name: Upload plugin jar
29-
uses: actions/upload-artifact@v1.0.0
28+
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
29+
- name: Upload artifact jar
30+
uses: actions/upload-artifact@v4
3031
with:
3132
# Artifact name
32-
name: Grails-Plugin-${{ steps.get_version.outputs.VERSION }}
33+
name: S3-Resource-Plugin-${{ steps.get_version.outputs.VERSION }}
3334
# Directory containing files to upload
34-
path: build/libs/aws-s3-model-source-${{ steps.get_version.outputs.VERSION }}.jar
35+
path: build/libs/*-${{ steps.get_version.outputs.VERSION }}.jar

.github/workflows/release.yml

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,43 @@ on:
22
push:
33
# Sequence of patterns matched against refs/tags
44
tags:
5-
- '*' # Push events to matching v*, i.e. v1.0, v20.15.10
5+
- 'v[0-9]+.[0-9]+.[0-9]+' # Push events to matching v*, i.e. v1.0, v20.15.10
66

7-
name: Upload Release Asset
7+
name: Publish Release
88

99
jobs:
1010
build:
11-
name: Upload Release Asset
11+
name: Publish Release
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
18-
- name: set up JDK 1.8
19-
uses: actions/setup-java@v1
18+
- name: Set up JDK 11
19+
uses: actions/setup-java@v4
2020
with:
21-
java-version: 1.8
21+
java-version: '11'
22+
distribution: 'zulu'
2223
- name: Build with Gradle
2324
run: ./gradlew build
2425
- name: Get Release Version
2526
id: get_version
26-
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo ::set-output name=VERSION::$VERSION
27+
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
2728
- name: Create Release
2829
id: create_release
29-
uses: actions/[email protected]
30+
run: |
31+
gh release create \
32+
--generate-notes \
33+
--title 'Release ${{ steps.get_version.outputs.VERSION }}' \
34+
${{ github.ref_name }} \
35+
build/libs/aws-s3-model-source-${{ steps.get_version.outputs.VERSION }}.jar
3036
env:
3137
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
with:
33-
tag_name: ${{ github.ref }}
34-
release_name: Release ${{ steps.get_version.outputs.VERSION }}
35-
draft: false
36-
prerelease: false
37-
- name: Upload Release Asset (jar)
38-
id: upload-release-asset
39-
uses: actions/upload-release-asset@v1
38+
- name: Publish to Maven Central
39+
run: ./gradlew -PsigningKey=${SIGNING_KEY_B64} -PsigningPassword=${SIGNING_PASSWORD} -PsonatypeUsername=${SONATYPE_USERNAME} -PsonatypePassword=${SONATYPE_PASSWORD} publishToSonatype closeAndReleaseSonatypeStagingRepository
4040
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
with:
43-
upload_url: ${{ steps.create_release.outputs.upload_url }}
44-
asset_path: build/libs/aws-s3-model-source-${{ steps.get_version.outputs.VERSION }}.jar
45-
asset_name: aws-s3-model-source-${{ steps.get_version.outputs.VERSION }}.jar
46-
asset_content_type: application/octet-stream
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: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,36 @@
1-
import org.gradle.api.tasks.testing.Test
2-
3-
/*
4-
* Copyright 2017 Rundeck, Inc. (http://rundeck.com)
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
18-
plugins{
19-
id 'pl.allegro.tech.build.axion-release' version '1.13.4'
1+
plugins {
2+
id 'java'
3+
id 'groovy'
4+
id 'idea'
5+
alias(libs.plugins.axionRelease)
6+
alias(libs.plugins.nexusPublish)
207
}
218

22-
23-
ext.rundeckPluginVersion = '1.2'
24-
ext.pluginClassNames=
25-
'com.rundeck.plugins.aws.S3ResourceModelSource'
9+
group = 'org.rundeck.plugins'
10+
ext.pluginClassNames='com.rundeck.plugins.aws.S3ResourceModelSource'
2611
ext.pluginName = 'S3 resource Model Source'
2712
ext.pluginDescription = 'Use Amazon S3 to store resources model file.'
13+
ext.publishName = "S3 Resource Model Source ${project.version}"
14+
ext.githubSlug = 'rundeck-plugins/aws-s3-model-source'
15+
ext.developers = [
16+
[id: 'gschueler', name: 'Greg Schueler', email: '[email protected]']
17+
]
2818

29-
apply plugin: 'java'
30-
apply plugin: 'groovy'
31-
32-
sourceCompatibility = 1.8
33-
targetCompatibility = 1.8
34-
35-
repositories {
36-
mavenCentral()
37-
mavenLocal()
38-
}
19+
ext.rundeckPluginVersion = '1.2'
3920

4021
scmVersion {
4122
tag {
4223
prefix = 'v'
4324
versionSeparator = ''
4425
}
26+
ignoreUncommittedChanges = true
4527
}
46-
version scmVersion.version
28+
29+
allprojects {
30+
project.version = scmVersion.version
31+
apply from: "${rootDir}/gradle/java.gradle"
32+
}
33+
4734
configurations {
4835
pluginLibs
4936

@@ -52,22 +39,27 @@ configurations {
5239
}
5340
}
5441

42+
repositories {
43+
mavenCentral()
44+
mavenLocal()
45+
}
46+
5547
dependencies {
56-
implementation group: 'org.rundeck', name: 'rundeck-core', version: '4.13.0-20230515'
57-
implementation "org.slf4j:slf4j-api:1.7.30"
58-
pluginLibs ('com.amazonaws:aws-java-sdk-s3:1.12.708') {
48+
implementation(libs.rundeckCore) {
49+
exclude group: "com.google.guava"
50+
}
51+
implementation libs.slf4jApi
52+
53+
pluginLibs(libs.awsSdkS3) {
5954
exclude group: "com.fasterxml.jackson.core"
6055
exclude group: "com.fasterxml.jackson.dataformat"
6156
}
62-
pluginLibs ('com.amazonaws:aws-java-sdk-sts:1.11.743') {
57+
pluginLibs(libs.awsSdkSts) {
6358
exclude group: "com.fasterxml.jackson.core"
6459
exclude group: "com.fasterxml.jackson.dataformat"
6560
}
6661

67-
testImplementation "org.codehaus.groovy:groovy-all:3.0.9"
68-
testImplementation "org.spockframework:spock-core:2.0-groovy-3.0"
69-
testImplementation "cglib:cglib-nodep:2.2.2"
70-
testImplementation 'org.objenesis:objenesis:1.4'
62+
testImplementation libs.bundles.testLibs
7163
}
7264

7365
task copyToLib(type: Copy) {
@@ -88,14 +80,25 @@ jar {
8880
attributes 'Rundeck-Plugin-Target-Host-Compatibility': 'all'
8981
attributes 'Rundeck-Plugin-Author': 'Rundeck, Inc.'
9082
attributes 'Rundeck-Plugin-Classnames': pluginClassNames
91-
attributes 'Rundeck-Plugin-File-Version': version
83+
attributes 'Rundeck-Plugin-File-Version': project.version
9284
attributes 'Rundeck-Plugin-Version': rundeckPluginVersion
9385
attributes 'Rundeck-Plugin-Archive': 'true'
9486
attributes 'Rundeck-Plugin-Libs': "${libList}"
9587
}
96-
dependsOn(copyToLib)
9788
}
9889

99-
tasks.withType(Test) {
90+
//set jar task to depend on copyToLib
91+
jar.dependsOn(copyToLib)
92+
93+
test {
10094
useJUnitPlatform()
101-
}
95+
}
96+
97+
nexusPublishing {
98+
packageGroup = 'org.rundeck.plugins'
99+
repositories {
100+
sonatype()
101+
}
102+
}
103+
104+
apply from: "${rootDir}/gradle/publishing.gradle"

gradle/java.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
java {
2+
sourceCompatibility = JavaVersion.VERSION_11
3+
withJavadocJar()
4+
withSourcesJar()
5+
}
6+
7+
allprojects {
8+
gradle.projectsEvaluated {
9+
tasks.withType(JavaCompile).configureEach {
10+
options.compilerArgs.add("-Xlint:deprecation")
11+
}
12+
}
13+
}

gradle/libs.versions.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[versions]
2+
axionRelease = "1.18.18"
3+
groovy = "3.0.24"
4+
rundeckCore = "5.10.0-20250312"
5+
nexusPublish = "2.0.0"
6+
spock = "2.3-groovy-3.0"
7+
awsSdk = "1.12.708"
8+
cglib = "2.2.2"
9+
objenesis = "1.4"
10+
slf4j = "1.7.30"
11+
12+
[libraries]
13+
rundeckCore = { group = "org.rundeck", name = "rundeck-core", version.ref = "rundeckCore" }
14+
groovyAll = { group = "org.codehaus.groovy", name = "groovy-all", version.ref = "groovy" }
15+
spockCore = { group = "org.spockframework", name = "spock-core", version.ref = "spock" }
16+
awsSdkS3 = { group = "com.amazonaws", name = "aws-java-sdk-s3", version.ref = "awsSdk" }
17+
awsSdkSts = { group = "com.amazonaws", name = "aws-java-sdk-sts", version.ref = "awsSdk" }
18+
cglibNodep = { group = "cglib", name = "cglib-nodep", version.ref = "cglib" }
19+
objenesis = { group = "org.objenesis", name = "objenesis", version.ref = "objenesis" }
20+
slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
21+
22+
[bundles]
23+
testLibs = ["groovyAll", "spockCore", "cglibNodep", "objenesis"]
24+
25+
[plugins]
26+
axionRelease = { id = "pl.allegro.tech.build.axion-release", version.ref = "axionRelease" }
27+
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('pluginDescription') ? project.ext.pluginDescription :
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)