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 @@ -9,6 +9,8 @@ jobs:
build:
name: Publish Release
runs-on: ubuntu-latest
env:
PKGCLD_REPO_URL: ${{ vars.PKGCLD_REPO_URL }}
steps:
- name: Checkout code
uses: actions/checkout@v7
Expand All @@ -33,10 +35,38 @@ jobs:
build/libs/docker-${{ steps.get_version.outputs.VERSION }}.zip
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/docker/${VERSION}"

Comment on lines +50 to +52
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"
}

# The published artifact is the pluginZip output, named after the Maven
# artifactId ("docker") with a ".jar" extension override.
sign_and_upload "build/libs/docker-${VERSION}.zip" "docker-${VERSION}.jar"
sign_and_upload "build/publications/mavenZip/pom-default.xml" "docker-${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 }}
12 changes: 1 addition & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'base'
id 'pl.allegro.tech.build.axion-release' version '1.21.2'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
}

group = 'org.rundeck.plugins'
Expand Down Expand Up @@ -96,16 +96,6 @@ pluginZip.doFirst {
}
}

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/"))
}
}
}

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

tasks.named('build').configure { dependsOn(pluginZip) }
Expand Down
39 changes: 12 additions & 27 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Zip-based Rundeck plugin publication for Maven Central (artifact uploaded as type jar).
* Zip-based Rundeck plugin publication (artifact uploaded as type jar).
* Requires: ext.publishName, ext.githubSlug, ext.developers; task pluginZip
*/
apply plugin: 'maven-publish'
apply plugin: 'signing'

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

publishing {
publications {
Expand Down Expand Up @@ -49,32 +50,16 @@ publishing {
}
}
repositories {
def pkgcldWriteToken = System.getenv("PKGCLD_WRITE_TOKEN") ?: project.findProperty("pkgcldWriteToken")
if (pkgcldWriteToken) {
maven {
name = "PackageCloudTest"
url = uri("https://packagecloud.io/pagerduty/rundeckpro-test/maven2")
authentication {
header(HttpHeaderAuthentication)
}
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = "Bearer " + pkgcldWriteToken
}
maven {
name = "PackageCloud"
url = uri(pkgcldRepoUrl)
authentication {
header(HttpHeaderAuthentication)
}
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = "Bearer " + (System.getenv("PKGCLD_WRITE_TOKEN") ?: project.findProperty("pkgcldWriteToken"))
}
Comment on lines +59 to 62
}
}
}

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)
}
}