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/py-winrm-plugin-${{ 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/py-winrm-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"
}

# This plugin publishes its pluginZip output as a Maven artifact with a
# ".jar" extension override, even though the local build output is a .zip.
sign_and_upload "build/libs/py-winrm-plugin-${VERSION}.zip" "py-winrm-plugin-${VERSION}.jar"
sign_and_upload "build/publications/mavenZip/pom-default.xml" "py-winrm-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 }}
Comment on lines +38 to +46
11 changes: 0 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ buildscript {
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 @@ -94,14 +93,4 @@ pluginZip.doFirst {
// Wire into build lifecycle
assemble.dependsOn pluginZip

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

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