From df4755b166c86d6feb837ef4657bcfb8c9e68bb4 Mon Sep 17 00:00:00 2001 From: Calum Calder Date: Sat, 22 Feb 2025 09:50:46 +0000 Subject: [PATCH] fix(ci): set up signing at root project level (#1435) This is required to sign the pom when uploading artifacts Ran an test upload to validate it end-to-end: ![Screenshot 2025-02-20 at 12 05 50](https://github.com/user-attachments/assets/11ef1b81-1438-41ed-be41-9f3feeb47876) --- build.gradle | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 98d486d06..c9c59740d 100644 --- a/build.gradle +++ b/build.gradle @@ -115,6 +115,23 @@ def addCloudExtensionDependency(proj) { proj.dependencies { compile project(":extensions:cloud:portability-cloud-${proj.rootProject.ext.cloudType}") } } +def configureSigning(Project project) { + if (project.hasProperty("signing.keyId")) { + project.signing { + sign project.configurations.archives + } + } else if (System.getenv("GRADLE_SIGNING_KEY")) { + // For use in CI + project.signing { + def signingKey = System.getenv('GRADLE_SIGNING_KEY') + def signingPassword = System.getenv('GRADLE_SIGNING_PASSWORD') + useInMemoryPgpKeys(signingKey, signingPassword) + sign project.configurations.archives + } + } +} +configureSigning(project) + /** * Configures the project to publish Maven artifacts to Maven Central. */ @@ -123,6 +140,7 @@ def configurePublication(Project project) { archives project.javadocJar, project.sourcesJar } + configureSigning(project) // Configure artifact publication project.uploadArchives { @@ -175,20 +193,6 @@ def configurePublication(Project project) { } } } - - if (project.hasProperty("signing.keyId")) { - project.signing { - sign project.configurations.archives - } - } else if (System.getenv("GRADLE_SIGNING_KEY")) { - // For use in CI - project.signing { - def signingKey = System.getenv('GRADLE_SIGNING_KEY') - def signingPassword = System.getenv('GRADLE_SIGNING_PASSWORD') - useInMemoryPgpKeys(signingKey, signingPassword) - sign project.configurations.archives - } - } }