Skip to content

Commit 8f18c2d

Browse files
committed
Update Release Process
1 parent 96b94cf commit 8f18c2d

3 files changed

Lines changed: 136 additions & 29 deletions

File tree

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
push:
3+
tags:
4+
- '*.*.*'
5+
6+
name: Publish Release
7+
8+
jobs:
9+
build:
10+
name: Publish Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '17'
21+
distribution: 'zulu'
22+
- name: Build with Gradle
23+
run: ./gradlew build
24+
- name: Get Release Version
25+
id: get_version
26+
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
27+
- name: Create Release
28+
run: |
29+
gh release create \
30+
--generate-notes \
31+
--title 'Release ${{ steps.get_version.outputs.VERSION }}' \
32+
${{ github.ref_name }} \
33+
build/libs/yaml-text-source-${{ steps.get_version.outputs.VERSION }}.zip
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Publish to Maven Central
37+
run: ./gradlew -PsigningKey=${SIGNING_KEY_B64} -PsigningPassword=${SIGNING_PASSWORD} -PsonatypeUsername=${SONATYPE_USERNAME} -PsonatypePassword=${SONATYPE_PASSWORD} publishToSonatype closeAndReleaseSonatypeStagingRepository
38+
env:
39+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
40+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
41+
SIGNING_KEY_B64: ${{ secrets.SIGNING_KEY_B64 }}
42+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

build.gradle

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugins {
22
id 'java'
33
id 'pl.allegro.tech.build.axion-release' version '1.18.17'
4-
id 'maven-publish'
4+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
55
}
66

7-
group = 'com.rundeck.plugins'
7+
group = 'org.rundeck.plugins'
88

99
repositories {
1010
mavenCentral()
@@ -32,6 +32,11 @@ scmVersion {
3232

3333
version = scmVersion.version // Dynamic version from git tag
3434
ext.archiveFilename = ext.archivesBaseName + '-' + version
35+
ext.publishName = "YAML Test Source ${project.version}"
36+
ext.githubSlug = 'rundeck-plugins/yaml-text-source'
37+
ext.developers = [
38+
[id: 'gschueler', name: 'Greg Schueler', email: 'greg@rundeck.com']
39+
]
3540

3641
// Plugin ZIP task (modernized from the external script)
3742
tasks.register('pluginZip', Jar) {
@@ -89,38 +94,18 @@ tasks.register('pluginZip', Jar) {
8994
}
9095
}
9196

92-
publishing {
93-
publications {
94-
mavenZip(MavenPublication) {
95-
groupId = 'com.rundeck.plugins'
96-
artifactId = 'yaml-text-source'
97-
version = project.version
98-
99-
artifact(pluginZip) {
100-
extension = 'jar' // CRITICAL: Publish as .jar to Maven repository
101-
}
102-
103-
pom {
104-
packaging = 'jar'
105-
}
106-
}
107-
}
108-
97+
nexusPublishing {
98+
packageGroup = 'org.rundeck.plugins'
10999
repositories {
110-
maven {
111-
name = "PackageCloudTest"
112-
url = uri("https://packagecloud.io/pagerduty/rundeckpro-test/maven2")
113-
authentication {
114-
header(HttpHeaderAuthentication)
115-
}
116-
credentials(HttpHeaderCredentials) {
117-
name = "Authorization"
118-
value = "Bearer " + (System.getenv("PKGCLD_WRITE_TOKEN") ?: project.findProperty("pkgcldWriteToken"))
119-
}
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/"))
120103
}
121104
}
122105
}
123106

107+
apply from: "${rootDir}/gradle/publishing.gradle"
108+
124109
build {
125110
dependsOn 'pluginZip'
126111
}

gradle/publishing.gradle

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* Zip-based Rundeck plugin publication for Maven Central (artifact uploaded as type jar).
3+
* Requires: ext.publishName, ext.githubSlug, ext.developers; task pluginZip
4+
*/
5+
apply plugin: 'maven-publish'
6+
apply plugin: 'signing'
7+
8+
publishing {
9+
publications {
10+
mavenZip(MavenPublication) {
11+
groupId = project.group.toString()
12+
artifactId = 'yaml-text-source'
13+
version = project.version.toString()
14+
15+
artifact(tasks.named('pluginZip')) {
16+
extension = 'jar'
17+
}
18+
19+
pom {
20+
packaging = 'jar'
21+
name = publishName
22+
description = project.ext.hasProperty('publishDescription') ? project.ext.publishDescription :
23+
project.description ?: publishName
24+
url = "https://github.com/${githubSlug}"
25+
licenses {
26+
license {
27+
name = 'The Apache Software License, Version 2.0'
28+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
29+
distribution = 'repo'
30+
}
31+
}
32+
scm {
33+
url = "https://github.com/${githubSlug}"
34+
connection = "scm:git:git@github.com/${githubSlug}.git"
35+
developerConnection = "scm:git:git@github.com:${githubSlug}.git"
36+
}
37+
if (project.ext.developers) {
38+
developers {
39+
project.ext.developers.each { dev ->
40+
developer {
41+
id = dev.id
42+
name = dev.name
43+
email = dev.email
44+
}
45+
}
46+
}
47+
}
48+
}
49+
}
50+
}
51+
repositories {
52+
def pkgcldWriteToken = System.getenv("PKGCLD_WRITE_TOKEN") ?: project.findProperty("pkgcldWriteToken")
53+
if (pkgcldWriteToken) {
54+
maven {
55+
name = "PackageCloudTest"
56+
url = uri("https://packagecloud.io/pagerduty/rundeckpro-test/maven2")
57+
authentication {
58+
header(HttpHeaderAuthentication)
59+
}
60+
credentials(HttpHeaderCredentials) {
61+
name = "Authorization"
62+
value = "Bearer " + pkgcldWriteToken
63+
}
64+
}
65+
}
66+
}
67+
}
68+
69+
def base64Decode = { String prop ->
70+
project.findProperty(prop) ?
71+
new String(Base64.getDecoder().decode(project.findProperty(prop).toString())).trim() :
72+
null
73+
}
74+
75+
if (project.hasProperty('signingKey') && project.hasProperty('signingPassword')) {
76+
signing {
77+
useInMemoryPgpKeys(base64Decode("signingKey"), project.signingPassword)
78+
sign(publishing.publications)
79+
}
80+
}

0 commit comments

Comments
 (0)