Property fixes

This commit is contained in:
crschnick 2024-03-15 15:10:59 +00:00
parent 3a47755c73
commit 7c9029134f
3 changed files with 27 additions and 7 deletions

View file

@ -97,6 +97,16 @@ project.ext {
file("$rootDir/dist/changelogs/${versionString}.md") :
file("$rootDir/dist/changelogs/${canonicalVersionString}.md")
incrementalChangelogFile = file("$rootDir/dist/changelogs/${canonicalVersionString}_incremental.md")
signingKeyId = project.hasProperty('signingKeyId') ? project.property("signingKeyId") : System.getenv('GPG_KEY_ID')
signingPassword = project.hasProperty('signingKeyPassword') ? project.property("signingKeyPassword") : System.getenv('GPG_KEY_PASSWORD')
if (signingPassword == null) {
signingPassword = ''
}
signingKeyRingFile = project.hasProperty('signingKeyFile') ? file(project.property("signingKeyFile")) : null
if (signingKeyRingFile == null || !signingKeyRingFile.exists()) {
signingKeyRingFile = file("$rootDir/dist/tools/secring.gpg")
}
signingKey = signingKeyRingFile.exists() ? signingKeyRingFile.text : System.getenv('GPG_KEY')
}
if (org.gradle.internal.os.OperatingSystem.current() == org.gradle.internal.os.OperatingSystem.LINUX) {

17
dist/build.gradle vendored
View file

@ -5,6 +5,7 @@ plugins {
id 'org.jreleaser' version '1.8.0'
id("com.netflix.nebula.ospackage") version "11.4.0"
id 'org.gradle.crypto.checksum' version '1.4.0'
id 'signing'
}
repositories {
@ -36,7 +37,7 @@ task createChecksums(type: Checksum) {
doLast {
def artifactChecksumsSha256Hex = new HashMap<String, String>()
for (final def file in outputDirectory.get().getAsFileTree().files) {
if (file.toString().endsWith('mapping.map')) {
if (file.toString().endsWith('mapping.map') || file.toString().endsWith('.asc')) {
continue
}
@ -90,4 +91,18 @@ if (rootProject.fullVersion) {
apply from: 'choco.gradle'
apply from: 'winget.gradle'
apply from: 'install.gradle'
signing {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
}
task signArtifacts(type: Sign) {
def dir = layout.buildDirectory.dir("dist/artifacts").get()
dir.asFileTree.files.forEach {sign(it)}
}
task signChecksums(type: Sign) {
def checksums = layout.buildDirectory.file("dist/checksums/sha256sums.txt").get().asFile
sign(checksums)
}
}

View file

@ -28,13 +28,8 @@ publishing {
}
}
def signingKeyId = project.hasProperty('signingKeyId') ? project.property("signingKeyId") : System.getenv('GPG_KEY_ID')
def signingKey = project.hasProperty('signingKeyFile') ? file(project.property("signingKeyFile")).text : System.getenv('GPG_KEY')
def signingPassword = project.hasProperty('signingPassword') ? project.property("signingPassword") : System.getenv('GPG_KEY_PASSWORD')
signing {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword != null ? signingPassword : '')
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign publishing.publications.mavenJava
}