Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
env:
PKGCLD_REPO_URL: ${{ vars.PKGCLD_REPO_URL }}
steps:
- name: Checkout code
uses: actions/checkout@v7
Expand All @@ -36,10 +38,38 @@ jobs:
build/libs/git-plugin-${{ steps.get_version.outputs.VERSION }}.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Maven Central
run: ./gradlew -PsigningKey=${SIGNING_KEY_B64} -PsigningPassword=${SIGNING_PASSWORD} -PsonatypeUsername=${SONATYPE_USERNAME} -PsonatypePassword=${SONATYPE_PASSWORD} publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Publish to PackageCloud
run: |
if [ -z "$PKGCLD_WRITE_TOKEN" ]; then
echo "::error::PKGCLD_WRITE_TOKEN must be set to publish to PackageCloud"
exit 1
fi
./gradlew publishAllPublicationsToPackageCloudRepository
env:
PKGCLD_WRITE_TOKEN: ${{ secrets.PKGCLD_WRITE_TOKEN }}
- name: Sign and upload GPG signatures to PackageCloud
run: |
set -e
VERSION="${{ steps.get_version.outputs.VERSION }}"
BASE_URL="${PKGCLD_REPO_URL:-https://packagecloud.io/pagerduty/rundeck-plugins/maven2}/org/rundeck/plugins/git-plugin/${VERSION}"

echo "$SIGNING_KEY_B64" | base64 -d | gpg --batch --yes --import
KEY_ID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/ {print $5; exit}')

sign_and_upload() {
local FILE="$1"
local REMOTE_NAME="$2"
gpg --batch --yes --pinentry-mode loopback --passphrase "$SIGNING_PASSWORD" --default-key "$KEY_ID" --detach-sign --armor "$FILE"
curl -sf -H "Authorization: Bearer ${PKGCLD_WRITE_TOKEN}" \
-X PUT --data-binary "@${FILE}.asc" \
"${BASE_URL}/${REMOTE_NAME}.asc"
}

sign_and_upload "build/libs/git-plugin-${VERSION}.jar" "git-plugin-${VERSION}.jar"
sign_and_upload "build/libs/git-plugin-${VERSION}-sources.jar" "git-plugin-${VERSION}-sources.jar"
sign_and_upload "build/libs/git-plugin-${VERSION}-javadoc.jar" "git-plugin-${VERSION}-javadoc.jar"
sign_and_upload "build/publications/git-plugin/pom-default.xml" "git-plugin-${VERSION}.pom"
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SIGNING_KEY_B64: ${{ secrets.SIGNING_KEY_B64 }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
PKGCLD_WRITE_TOKEN: ${{ secrets.PKGCLD_WRITE_TOKEN }}
18 changes: 4 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
alias(libs.plugins.axionRelease)
alias(libs.plugins.nexusPublish)
id 'java'
}

Expand Down Expand Up @@ -121,16 +120,6 @@ jar {
dependsOn(copyToLib)
}

nexusPublishing {
packageGroup = 'org.rundeck.plugins'
repositories {
sonatype {
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
}
}
}

test {
useJUnitPlatform()
// Java 17 requires these for cglib/Spock mocking
Expand All @@ -140,12 +129,13 @@ test {

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

// Add PackageCloud repository
def pkgcldRepoUrl = (System.getenv("PKGCLD_REPO_URL") ?: "https://packagecloud.io/pagerduty/rundeck-plugins/maven2").trim()

publishing {
repositories {
maven {
name = "PackageCloudTest"
url = uri("https://packagecloud.io/pagerduty/rundeckpro-test/maven2")
name = "PackageCloud"
url = uri(pkgcldRepoUrl)
authentication {
header(HttpHeaderAuthentication)
}
Expand Down
4 changes: 1 addition & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[versions]
# Plugins
axionRelease = "1.21.2"
nexusPublish = "2.0.0"
# Libraries
groovy = "4.0.32"
junit = "4.13.2"
Expand Down Expand Up @@ -33,5 +32,4 @@ commonsLang3 = { module = "org.apache.commons:commons-lang3", version.ref = "com
testLibs = ["junit", "groovyAll", "spockCore", "bytebuddy", "objenesis"]

[plugins]
axionRelease = { id = "pl.allegro.tech.build.axion-release", version.ref = "axionRelease" }
nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublish" }
axionRelease = { id = "pl.allegro.tech.build.axion-release", version.ref = "axionRelease" }
21 changes: 0 additions & 21 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@
* githubSlug = Github slug e.g. 'rundeck/rundeck-cli'
* developers = [ [id:'id', name:'name', email: 'email' ] ] list of developers
*
* Define project properties to sign and publish when invoking publish task:
*
* ./gradlew \
* -PsigningKey="base64 encoded gpg key" \
* -PsigningPassword="password for key" \
* -PsonatypeUsername="sonatype token user" \
* -PsonatypePassword="sonatype token password" \
* publishToSonatype closeAndReleaseSonatypeStagingRepository
*/
apply plugin: 'maven-publish'
apply plugin: 'signing'

publishing {
publications {
Expand Down Expand Up @@ -55,16 +46,4 @@ publishing {

}
}
}
def base64Decode = { String prop ->
project.findProperty(prop) ?
new String(Base64.getDecoder().decode(project.findProperty(prop).toString())).trim() :
null
}

if (project.hasProperty('signingKey') && project.hasProperty('signingPassword')) {
signing {
useInMemoryPgpKeys(base64Decode("signingKey"), project.signingPassword)
sign(publishing.publications)
}
}