Skip to content

Commit 1722759

Browse files
authored
Merge pull request #74 from rundeck-plugins/build-updates
RUN-3592: Modernize build configuration and update GitHub workflows
2 parents c996b11 + 1a78f68 commit 1722759

File tree

6 files changed

+141
-51
lines changed

6 files changed

+141
-51
lines changed

.github/workflows/gradle.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525
run: ./gradlew build
2626
- name: Get Release Version
2727
id: get_version
28-
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo ::set-output name=VERSION::$VERSION
29-
- name: Upload sshj-plugin jar
28+
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
29+
- name: Upload artifact jar
3030
uses: actions/upload-artifact@v4
3131
with:
3232
# Artifact name
33-
name: Grails-Plugin-${{ steps.get_version.outputs.VERSION }}
33+
name: SSHJ-Plugin-${{ steps.get_version.outputs.VERSION }}
3434
# Directory containing files to upload
35-
path: build/libs/sshj-plugin-${{ steps.get_version.outputs.VERSION }}.jar
35+
path: build/libs/*-${{ steps.get_version.outputs.VERSION }}.jar

.github/workflows/release.yml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ on:
22
push:
33
# Sequence of patterns matched against refs/tags
44
tags:
5-
- 'v*' # 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
1515
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
18-
- name: set up JDK 11
18+
- name: Set up JDK 11
1919
uses: actions/setup-java@v4
2020
with:
2121
java-version: '11'
@@ -24,24 +24,21 @@ jobs:
2424
run: ./gradlew build
2525
- name: Get Release Version
2626
id: get_version
27-
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
2828
- name: Create Release
2929
id: create_release
30-
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/sshj-plugin-${{ steps.get_version.outputs.VERSION }}.jar
3136
env:
3237
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
with:
34-
tag_name: ${{ github.ref }}
35-
release_name: Release ${{ steps.get_version.outputs.VERSION }}
36-
draft: false
37-
prerelease: false
38-
- name: Upload Release Asset (jar)
39-
id: upload-release-asset
40-
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
4140
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
with:
44-
upload_url: ${{ steps.create_release.outputs.upload_url }}
45-
asset_path: build/libs/sshj-plugin-${{ steps.get_version.outputs.VERSION }}.jar
46-
asset_name: sshj-plugin-${{ steps.get_version.outputs.VERSION }}.jar
47-
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: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
plugins {
2-
alias(libs.plugins.axionRelease)
32
id 'java'
4-
id 'maven-publish'
3+
id 'groovy'
4+
id 'idea'
5+
alias(libs.plugins.axionRelease)
6+
alias(libs.plugins.nexusPublish)
57
}
68

7-
defaultTasks 'clean','build'
8-
apply plugin: 'java'
9-
apply plugin: 'groovy'
10-
apply plugin: 'idea'
11-
12-
ext.rundeckPluginVersion= '1.2'
13-
ext.rundeckVersion= '3.3.x'
9+
group = 'org.rundeck.plugins'
1410
ext.pluginClassNames='com.plugin.sshjplugin.SSHJNodeExecutorPlugin,com.plugin.sshjplugin.SSHJFileCopierPlugin'
1511
ext.pluginName = 'SSHJ Plugin'
16-
ext.pluginDescription ='SSH Node Executor and File Copier plugin based on SSHJ library.'
17-
18-
java {
19-
sourceCompatibility = JavaVersion.VERSION_11
20-
targetCompatibility = JavaVersion.VERSION_11
21-
}
12+
ext.pluginDescription = 'SSH Node Executor and File Copier plugin based on SSHJ library.'
13+
ext.rundeckPluginVersion= '1.2'
14+
ext.publishName = "SSHJ Plugin ${project.version}"
15+
ext.githubSlug = 'rundeck-plugins/sshj-plugin'
16+
ext.developers = [
17+
[id: 'gschueler', name: 'Greg Schueler', email: '[email protected]']
18+
]
2219

2320
scmVersion {
2421
ignoreUncommittedChanges = true
@@ -28,7 +25,12 @@ scmVersion {
2825
}
2926
}
3027

31-
project.version = scmVersion.version
28+
allprojects {
29+
project.version = scmVersion.version
30+
apply from: "${rootDir}/gradle/java.gradle"
31+
}
32+
33+
defaultTasks 'clean','build'
3234

3335
repositories {
3436
mavenLocal()
@@ -75,25 +77,31 @@ jar {
7577
attributes 'Rundeck-Plugin-Rundeck-Compatibility-Version': '2.x+'
7678
attributes 'Rundeck-Plugin-Tags': 'java,executor'
7779
attributes 'Rundeck-Plugin-License': 'MIT'
78-
attributes 'Rundeck-Plugin-Source-Link': 'https://github.com/rundeck-plugins'
80+
attributes 'Rundeck-Plugin-Source-Link': 'https://github.com/rundeck-plugins/sshj-plugin'
7981
attributes 'Rundeck-Plugin-Target-Host-Compatibility': 'all'
8082
attributes 'Rundeck-Plugin-Author': 'Rundeck, Inc.'
8183
attributes 'Rundeck-Plugin-Classnames': pluginClassNames
82-
attributes 'Rundeck-Plugin-File-Version': version
84+
attributes 'Rundeck-Plugin-File-Version': project.version
8385
attributes 'Rundeck-Plugin-Version': rundeckPluginVersion, 'Rundeck-Plugin-Archive': 'true'
8486
attributes 'Rundeck-Plugin-Libs': "${libList}"
85-
attributes 'Class-Path': "${libList} lib/rundeck-core-${rundeckVersion}.jar"
8687
}
8788
}
89+
90+
test {
91+
useJUnitPlatform()
92+
}
93+
8894
//set jar task to depend on copyToLib
8995
jar.dependsOn(copyToLib)
9096

91-
92-
publishing {
93-
publications {
94-
maven(MavenPublication) {
95-
artifactId = 'jq-json-logfilter'
96-
from components.java
97+
nexusPublishing {
98+
packageGroup = 'org.rundeck.plugins'
99+
repositories {
100+
sonatype {
101+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
102+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
97103
}
98104
}
99-
}
105+
}
106+
107+
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ groovy = "3.0.22"
1212
spock = "2.0-groovy-3.0"
1313
cglib = "3.3.0"
1414
objenesis = "1.4"
15-
axionRelease = "1.18.14"
15+
axionRelease = "1.18.18"
16+
nexusPublish = "2.0.0"
1617

1718
[libraries]
1819
sshj = { group = "com.hierynomus", name = "sshj", version.ref = "sshj" }
@@ -36,3 +37,4 @@ testLibs = ["junit", "groovyAll", "spockCore", "cglibNodep", "objenesis"]
3637

3738
[plugins]
3839
axionRelease = { id = "pl.allegro.tech.build.axion-release", version.ref = "axionRelease" }
40+
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)