v1.0.0 release(run 9)가 :grpc:grpc-contract:signMavenPublication에서 「Could not read PGP secret key」로 멈췄다. 원인 사슬은 BouncyCastle의 「secret key ring doesn't start with secret key tag: tag 0x37」이다. Gradle은 키 문자열이 망가진 경우와 비밀번호가 틀린 경우를 같은 문장으로 알리고, secret은 로그에서 볼 수 없어 무엇이 틀렸는지 가릴 길이 없었다. scripts/release/check-signing-key.sh가 값을 출력하지 않고 본다: - 모양: 글자·줄 수, CR, 「\n」 문자열, 비ASCII, 앞뒤 공백 - armour: 첫 줄 BEGIN, 끝 줄 END, BEGIN 뒤 빈 줄 - base64 본문: 줄 너비, CRC24가 checksum 줄과 맞는지, 첫 패킷이 비밀 키(tag 5)인지 - gpg가 가져오는지, 가져온 키의 지문(공개 정보)이 릴리스 키인지 - SIGNING_PASSWORD로 서명되는지(성공/실패만) Gradle 태스크 verifySigningKey가 이 스크립트를 부른다. `release`는 이것에 의존하고(서명 키가 있으면 releaseRehearsal도), 모든 Sign 태스크는 그 뒤에 돈다. release.yml은 그대로 한 줄이다. 태그 없이 돌리는 수동 workflow signing-check.yml을 더했다. 릴리스 키 지문은 gradle.properties signingKeyFingerprint다. 검증(desktop, 버리는 RSA 4096 키): 정상 키 rc=0(모든 칸 yes, 서명 ok). base64 줄 하나 뺀 키·한 줄로 붙인 키·틀린 비밀번호·다른 키는 각각 rc=1과 그 원인 줄. 같은 BouncyCastle 1.81로 망가뜨린 모양별 오류를 재현했다. 줄 누락은 tag 0x1·0xc·0xf처럼 임의의 tag를 낸다. 한 줄로 붙이거나 공백· 「\n」이 섞이면 0xffffffff, 비밀번호가 틀리면 checksum mismatch다.
288 lines
13 KiB
Groovy
288 lines
13 KiB
Groovy
import dev.caskeleton.buildlogic.java.JavaConventionsPlugin
|
|
|
|
plugins {
|
|
id 'ca.architecture'
|
|
// Every strict lane belongs to a stage a workflow executes (.gitea/workflows). Without it a lane
|
|
// that fails closed can still run nowhere (template review 2026-11-03 RR-06-03).
|
|
id 'ca.strict-lane-stages'
|
|
// The release SBOM is published as an artifact of its own, `grpc-library`, next to the modules.
|
|
id 'maven-publish'
|
|
id 'signing'
|
|
}
|
|
|
|
// The modules: every leaf the registry includes (settings.gradle). The family projects `:grpc` and
|
|
// `:grpc-advanced` are folders, not modules.
|
|
def leaves = subprojects.findAll { it.childProjects.isEmpty() }
|
|
def leafPaths = leaves.collect { it.path }
|
|
|
|
// The root's coordinate is the release's: the SBOM artifact carries the version the modules carry.
|
|
group = providers.gradleProperty('libraryGroup').get()
|
|
def revision = JavaConventionsPlugin.sourceRevision(providers)
|
|
version = JavaConventionsPlugin.releaseVersion(providers) +
|
|
(revision == JavaConventionsPlugin.UNKNOWN_REVISION ? '-SNAPSHOT' : '')
|
|
// Captured here: inside a task's configuration `group` and `version` are the task's own properties.
|
|
def libraryCoordinates = [project.group.toString(), project.version.toString()]
|
|
|
|
tasks.register('resolveAndLockAll') {
|
|
group = 'build setup'
|
|
description = 'Regenerates dependency locks for every module (requires --write-locks).'
|
|
dependsOn leafPaths.collect { "${it}:resolveAndLockAll" }
|
|
}
|
|
|
|
tasks.register('verifyDependencyLocks') {
|
|
group = 'verification'
|
|
description = 'Fails when a module resolves something its strict lockfile does not list.'
|
|
dependsOn leafPaths.collect { "${it}:verifyDependencyLocks" }
|
|
}
|
|
|
|
tasks.register('checkAll') {
|
|
group = 'verification'
|
|
description = 'Runs every module check.'
|
|
dependsOn leafPaths.collect { "${it}:check" }
|
|
}
|
|
|
|
tasks.register('qualityCheck') {
|
|
group = 'verification'
|
|
description = 'Runs production-bytecode static analysis for every module.'
|
|
dependsOn leafPaths.collect { "${it}:qualityCheck" }
|
|
}
|
|
|
|
// SpotBugs + FindSecBugs over the test source sets (config/spotbugs/exclude-test.xml). Short here
|
|
// (nine modules), so it joins `ci`.
|
|
tasks.register('testQualityCheck') {
|
|
group = 'verification'
|
|
description = 'Runs test-code static analysis for every module.'
|
|
dependsOn leafPaths.collect { "${it}:testQualityCheck" }
|
|
}
|
|
|
|
// build-logic is a copy of the template's convention plugins (build-logic/UPSTREAM.md); its own
|
|
// TestKit and unit tests keep the copy honest when it is changed here.
|
|
tasks.register('buildLogicTest') {
|
|
group = 'verification'
|
|
description = 'Runs the included build-logic build\'s tests.'
|
|
dependsOn gradle.includedBuild('build-logic').task(':test')
|
|
}
|
|
|
|
// The pull-request stage (pr.yml). Buf lint and breaking-change policy run here rather than in each
|
|
// module's `check`: Buf is a downloaded binary and the breaking check reads Git history, which a
|
|
// local `./gradlew :grpc:grpc-contract:check` should not need.
|
|
tasks.register('ci') {
|
|
group = 'verification'
|
|
description = 'The pull-request stage: module checks, architecture, static analysis, locks, Buf and build-logic tests.'
|
|
dependsOn tasks.named('checkAll')
|
|
dependsOn tasks.named('qualityCheck')
|
|
dependsOn tasks.named('testQualityCheck')
|
|
dependsOn tasks.named('verifyDependencyLocks')
|
|
// architectureCheck, not only the direction gate: it also runs verifyNoIgnoredSourcePackages.
|
|
dependsOn tasks.named('architectureCheck')
|
|
dependsOn ':grpc:grpc-contract:bufLint', ':grpc:grpc-contract:bufBreaking'
|
|
dependsOn tasks.named('buildLogicTest')
|
|
}
|
|
|
|
// Every module's integration lanes: grpc-operation-ledger-jpa's Testcontainers PostgreSQL lane, which
|
|
// certifies the atomic `INSERT ... ON CONFLICT DO NOTHING` claim durable idempotency rests on. Needs a
|
|
// container runtime.
|
|
tasks.register('integrationCheck') {
|
|
group = 'verification'
|
|
description = 'Runs every module integration test lane. Needs a container runtime.'
|
|
dependsOn leafPaths.collect { "${it}:integrationTestLaneCheck" }
|
|
}
|
|
|
|
// grpcPerformanceTest asserts the shape of a measurement (ordered percentiles, a gate that reads
|
|
// them) with a generous budget, not a number, so it can run on a shared runner.
|
|
tasks.register('performanceCheck') {
|
|
group = 'verification'
|
|
description = 'Runs every module performance test lane.'
|
|
dependsOn leafPaths.collect { "${it}:performanceTestLaneCheck" }
|
|
}
|
|
|
|
// The main-branch stage (main.yml): the pull-request stage again on the merged commit, plus the lanes
|
|
// that start containers or measure.
|
|
tasks.register('mainCheck') {
|
|
group = 'verification'
|
|
description = 'The main-branch stage: ci, integrationCheck and performanceCheck.'
|
|
dependsOn tasks.named('ci')
|
|
dependsOn tasks.named('integrationCheck')
|
|
dependsOn tasks.named('performanceCheck')
|
|
}
|
|
|
|
// ---------------------------------------------------------------- release (release.yml)
|
|
|
|
def sbomFile = layout.buildDirectory.file("release/grpc-library-${version}-cyclonedx.json")
|
|
|
|
tasks.register('verifyReleaseVersion') {
|
|
group = 'verification'
|
|
description = 'Fails unless this build names a release version and the commit it was built from.'
|
|
def releaseVersion = libraryCoordinates[1]
|
|
doLast {
|
|
if (releaseVersion.endsWith('-SNAPSHOT')) {
|
|
throw new GradleException("No commit id (-PgitRevision, GIT_SHA or GITHUB_SHA): ${releaseVersion} is not a release.")
|
|
}
|
|
if (releaseVersion == '0.0.1') {
|
|
throw new GradleException('No release version: run with RELEASE_TAG=vX.Y.Z (release.yml) or -PreleaseVersion.')
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.register('releaseSbom', Exec) {
|
|
group = 'release'
|
|
description = 'Writes the CycloneDX SBOM of the published modules from their lockfiles (Trivy).'
|
|
outputs.file(sbomFile)
|
|
outputs.upToDateWhen { false }
|
|
commandLine 'bash', file('scripts/release/sbom.sh'), sbomFile.get().asFile
|
|
}
|
|
|
|
tasks.register('dependencyVulnerabilityScan', Exec) {
|
|
group = 'verification'
|
|
description = 'Fails on a HIGH or CRITICAL dependency vulnerability or any CISA KEV match (Trivy).'
|
|
mustRunAfter tasks.named('releaseSbom')
|
|
def reports = layout.buildDirectory.dir('release/vulnerability')
|
|
commandLine 'bash', file('scripts/release/vulnerability-scan.sh'), reports.get().asFile
|
|
}
|
|
|
|
// The tag-only stage: the hermetic certification lanes of every module (their tests already run in
|
|
// `test`; a lane adds that its tag still selects something), the integration lanes, the version
|
|
// check, the SBOM and the dependency gate. grpcPerformanceTest is not release evidence on a shared
|
|
// runner and stays in mainCheck.
|
|
tasks.register('releaseCheck') {
|
|
group = 'verification'
|
|
description = 'The release stage before publishing: certification and integration lanes, version, SBOM, dependency gate.'
|
|
dependsOn tasks.named('verifyReleaseVersion')
|
|
dependsOn leafPaths.collect { "${it}:testLaneCheck" }
|
|
dependsOn tasks.named('integrationCheck')
|
|
dependsOn tasks.named('releaseSbom')
|
|
dependsOn tasks.named('dependencyVulnerabilityScan')
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
sbom(MavenPublication) {
|
|
artifactId = 'grpc-library'
|
|
artifact(sbomFile) {
|
|
classifier = 'cyclonedx'
|
|
extension = 'json'
|
|
builtBy tasks.named('releaseSbom')
|
|
}
|
|
pom {
|
|
name = 'grpc-library'
|
|
description = 'CycloneDX SBOM of the grpc-library modules of this version.'
|
|
url = providers.gradleProperty('repositoryUrl')
|
|
packaging = 'pom'
|
|
}
|
|
}
|
|
}
|
|
repositories {
|
|
maven {
|
|
name = 'gitea'
|
|
url = providers.gradleProperty('packagesUrl')
|
|
credentials(HttpHeaderCredentials) {
|
|
name = 'Authorization'
|
|
value = "token ${providers.environmentVariable('PACKAGE_TOKEN').getOrElse('')}"
|
|
}
|
|
authentication {
|
|
header(HttpHeaderAuthentication)
|
|
}
|
|
}
|
|
maven {
|
|
name = 'staging'
|
|
url = layout.buildDirectory.dir('staging-repository')
|
|
}
|
|
}
|
|
}
|
|
|
|
def signingKey = providers.environmentVariable('SIGNING_KEY').getOrElse('')
|
|
|
|
// Before anything is signed: the secret's shape, that gpg imports it as the release key and that
|
|
// SIGNING_PASSWORD signs with it, printing no part of either. Gradle's signing reports every one of
|
|
// these as "Could not read PGP secret key" (v1.0.0 release run 9); this says which. A key other
|
|
// than the release key passes with -PsigningKeyFingerprint=<its fingerprint> (a rehearsal key).
|
|
tasks.register('verifySigningKey', Exec) {
|
|
group = 'verification'
|
|
description = 'Checks SIGNING_KEY and SIGNING_PASSWORD without printing them (scripts/release/check-signing-key.sh).'
|
|
outputs.upToDateWhen { false }
|
|
commandLine 'bash', file('scripts/release/check-signing-key.sh'),
|
|
providers.gradleProperty('signingKeyFingerprint').getOrElse('')
|
|
}
|
|
tasks.withType(Sign).configureEach {
|
|
mustRunAfter tasks.named('verifySigningKey')
|
|
}
|
|
if (!signingKey.isBlank()) {
|
|
signing {
|
|
useInMemoryPgpKeys(signingKey, providers.environmentVariable('SIGNING_PASSWORD').getOrElse(''))
|
|
sign publishing.publications.sbom
|
|
}
|
|
}
|
|
|
|
tasks.withType(PublishToMavenRepository).configureEach {
|
|
mustRunAfter tasks.named('releaseCheck')
|
|
if (name.endsWith('ToGiteaRepository')) {
|
|
def signed = !signingKey.isBlank()
|
|
def token = providers.environmentVariable('PACKAGE_TOKEN').getOrElse('')
|
|
doFirst {
|
|
if (!signed) {
|
|
throw new GradleException('SIGNING_KEY is not set; refusing to publish unsigned files to Gitea.')
|
|
}
|
|
if (token.isBlank()) {
|
|
throw new GradleException('PACKAGE_TOKEN is not set; Gitea\'s job token cannot publish packages.')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Everything release.yml does up to the upload, into build/staging-repository: what `release` would
|
|
// publish, checked file by file. Needs no secret; with SIGNING_KEY set it also checks every .asc.
|
|
tasks.register('releaseRehearsal') {
|
|
group = 'release'
|
|
description = 'releaseCheck, then publishes every module and the SBOM to build/staging-repository and checks the files.'
|
|
dependsOn tasks.named('releaseCheck')
|
|
if (!signingKey.isBlank()) {
|
|
dependsOn tasks.named('verifySigningKey')
|
|
}
|
|
dependsOn tasks.named('publishAllPublicationsToStagingRepository')
|
|
dependsOn leafPaths.collect { "${it}:publishAllPublicationsToStagingRepository" }
|
|
def staging = layout.buildDirectory.dir('staging-repository')
|
|
def artifacts = leaves.collect { it.name }
|
|
def coordinates = libraryCoordinates
|
|
def signed = !signingKey.isBlank()
|
|
def checker = file('scripts/release/check-staging.py')
|
|
doLast {
|
|
def command = ['python3', checker.path, staging.get().asFile.path, coordinates[0], coordinates[1],
|
|
signed ? 'signed' : 'unsigned'] + artifacts
|
|
def process = command.execute()
|
|
process.waitForProcessOutput(System.out, System.err)
|
|
if (process.exitValue() != 0) {
|
|
throw new GradleException('releaseRehearsal: the staged release is incomplete (see above).')
|
|
}
|
|
}
|
|
}
|
|
|
|
// The release: releaseCheck, then every module and the SBOM to Gitea Packages, then an anonymous read
|
|
// of each module's metadata. release.yml runs this one task on a vX.Y.Z tag.
|
|
tasks.register('release') {
|
|
group = 'release'
|
|
description = 'releaseCheck, publish to Gitea Packages, then verify the version is readable anonymously.'
|
|
dependsOn tasks.named('releaseCheck')
|
|
dependsOn tasks.named('verifySigningKey')
|
|
dependsOn tasks.named('publishAllPublicationsToGiteaRepository')
|
|
dependsOn leafPaths.collect { "${it}:publishAllPublicationsToGiteaRepository" }
|
|
def url = providers.gradleProperty('packagesUrl')
|
|
def artifacts = leaves.collect { it.name } + ['grpc-library']
|
|
def coordinates = libraryCoordinates
|
|
def verifier = file('scripts/release/verify-published.sh')
|
|
doLast {
|
|
def command = ['bash', verifier.path, url.get(), coordinates[0], coordinates[1]] + artifacts
|
|
def process = command.execute()
|
|
process.waitForProcessOutput(System.out, System.err)
|
|
if (process.exitValue() != 0) {
|
|
throw new GradleException('release: a published module is not readable anonymously (see above).')
|
|
}
|
|
}
|
|
}
|
|
|
|
// The stages a strict lane may belong to, executed by .gitea/workflows as `./gradlew <stage>` from the
|
|
// repository root. releaseCheck may run on a tag push only.
|
|
strictLaneStages {
|
|
stage ':ci', ':mainCheck', ':releaseCheck'
|
|
workflowDirectory = layout.projectDirectory.dir('.gitea/workflows')
|
|
}
|