Skip to content

Commit

Permalink
fix(ci): set up signing at root project level (#1435)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
calumcalder authored Feb 22, 2025
1 parent 32eb7cc commit df4755b
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -123,6 +140,7 @@ def configurePublication(Project project) {
archives project.javadocJar, project.sourcesJar
}

configureSigning(project)

// Configure artifact publication
project.uploadArchives {
Expand Down Expand Up @@ -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
}
}
}


Expand Down

0 comments on commit df4755b

Please sign in to comment.