Skip to content
Open
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
40 changes: 36 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@v4
Expand All @@ -33,10 +35,40 @@ jobs:
build/libs/openssh-node-execution-${{ 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/openssh-node-execution/${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"
}

# rootProject.name is "openssh-exec-plugin" (a stray build/libs/openssh-exec-plugin-*.jar
# also gets produced by the java plugin, but it's not what's published). The actual
# published artifact is the pluginZip output, named after the Maven artifactId
# ("openssh-node-execution") with a ".jar" extension override.
sign_and_upload "build/libs/openssh-node-execution-${VERSION}.zip" "openssh-node-execution-${VERSION}.jar"
sign_and_upload "build/publications/mavenZip/pom-default.xml" "openssh-node-execution-${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 }}
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 'java'
id 'pl.allegro.tech.build.axion-release' version '1.17.2'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
}

repositories {
Expand Down Expand Up @@ -116,16 +115,6 @@ tasks.named('pluginZip').configure {
}
}

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"

defaultTasks 'clean', 'build', 'pluginZip'
Expand Down
46 changes: 12 additions & 34 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
/**
* Zip-based Rundeck plugin publication for Maven Central (artifact uploaded as type jar).
* Zip-based Rundeck plugin publication (artifact uploaded as type jar).
*
* Requires before this file:
* - ext.publishName, ext.githubSlug, ext.developers
* - task pluginZip
*
* ./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'

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

publishing {
publications {
Expand Down Expand Up @@ -59,32 +53,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)
}
}
Loading