Skip to content

Commit 431e29f

Browse files
committed
Fixup Build/Release
1 parent ba0b2ab commit 431e29f

3 files changed

Lines changed: 104 additions & 36 deletions

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
on:
22
push:
3-
# Sequence of patterns matched against refs/tags
43
tags:
5-
- '*' # Push events to matching v*, i.e. v1.0, v20.15.10
4+
- '*.*.*'
65

7-
name: Create Release
6+
name: Publish Release
87

98
jobs:
109
build:
11-
name: Upload Release Asset
10+
name: Publish Release
1211
runs-on: ubuntu-latest
1312
steps:
1413
- name: Checkout code
@@ -25,8 +24,7 @@ jobs:
2524
- name: Get Release Version
2625
id: get_version
2726
run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
28-
- name: Create Release and Upload Asset
29-
id: create_release
27+
- name: Create Release
3028
run: |
3129
gh release create \
3230
--generate-notes \
@@ -35,4 +33,10 @@ jobs:
3533
build/libs/kubernetes-${{ steps.get_version.outputs.VERSION }}.zip
3634
env:
3735
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
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: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ buildscript {
99
plugins {
1010
id 'base'
1111
id 'pl.allegro.tech.build.axion-release' version '1.17.2'
12-
id 'maven-publish'
12+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
1313
}
1414

15-
group = 'com.rundeck.plugins'
15+
group = 'org.rundeck.plugins'
1616

1717
ext.pluginName = 'kubernetes'
1818
ext.pluginDescription = "Kubernetes Rundeck Plugin to manage pods , deployments, etc"
@@ -32,6 +32,11 @@ scmVersion {
3232
}
3333

3434
version = scmVersion.version // Dynamic version from git tag
35+
ext.publishName = "Kubernetes ${project.version}"
36+
ext.githubSlug = 'rundeck-plugins/kubernetes'
37+
ext.developers = [
38+
[id: 'gschueler', name: 'Greg Schueler', email: 'greg@rundeck.com']
39+
]
3540

3641
// ZIP plugin task - must use Jar type for proper manifest handling
3742
task pluginZip(type: Jar) {
@@ -95,35 +100,14 @@ pluginZip.doFirst {
95100
// Wire into build lifecycle
96101
assemble.dependsOn pluginZip
97102

98-
publishing {
99-
publications {
100-
mavenZip(MavenPublication) {
101-
groupId = 'com.rundeck.plugins'
102-
artifactId = 'kubernetes'
103-
version = project.version
104-
105-
artifact(pluginZip) {
106-
extension = 'jar' // Publish as .jar to Maven (it's actually a zip)
107-
}
108-
109-
pom {
110-
packaging = 'jar'
111-
}
112-
}
113-
}
114-
103+
nexusPublishing {
104+
packageGroup = 'org.rundeck.plugins'
115105
repositories {
116-
maven {
117-
name = "PackageCloudTest"
118-
url = uri("https://packagecloud.io/pagerduty/rundeckpro-test/maven2")
119-
authentication {
120-
header(HttpHeaderAuthentication)
121-
}
122-
credentials(HttpHeaderCredentials) {
123-
name = "Authorization"
124-
value = "Bearer " + (System.getenv("PKGCLD_WRITE_TOKEN") ?: project.findProperty("pkgcldWriteToken"))
125-
}
106+
sonatype {
107+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
108+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
126109
}
127110
}
128111
}
129112

113+
apply from: "${rootDir}/gradle/publishing.gradle"

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 = 'kubernetes'
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)