From 34d548fa54c07da40a53513b1c47012b8137db84 Mon Sep 17 00:00:00 2001 From: Jure Skelin Date: Thu, 21 Nov 2024 18:02:18 +0100 Subject: [PATCH] fix: prevent attempt of double publishing of cosign.pub --- .ci/releasePipeline.groovy | 47 ++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/.ci/releasePipeline.groovy b/.ci/releasePipeline.groovy index 8e0db660d..f9f6404fe 100644 --- a/.ci/releasePipeline.groovy +++ b/.ci/releasePipeline.groovy @@ -35,16 +35,7 @@ pipeline { stage("Build binaries") { def tasks = [:] - tasks["Docker container"] = { - stage("for testing") { - releaseDockerContainer(ctx, "DT") - } - if (isRelease(ctx)) { - stage ("for DockerHub") { - releaseDockerContainer(ctx, "DockerHub") - } - } - } + tasks["Docker container"] = { releaseDockerContainer(ctx) } //linux for (arch in ["amd64", "arm64", "386"]) { @@ -189,23 +180,35 @@ void releaseBinary(Context ctx, Release release) { } } -void releaseDockerContainer(Context ctx, String registry) { - stage("Build Docker") { - def ko = load(".ci/jenkins/tools/ko.groovy") - ko.install() - def cosign = load(".ci/jenkins/tools/cosign.groovy") - cosign.install("latest") +void releaseDockerContainer(Context ctx) { + stage("Build container for testing") { + createAndPublishContainer(ctx, "DT") + } + if (isRelease(ctx)) { + stage("Build container for DockerHub") { + createAndPublishContainer(ctx, "DockerHub") - List tags = [ctx.version] - if (isFinal(ctx)) { - tags << "latest" + def cosign = load(".ci/jenkins/tools/cosign.groovy") ctx.githubRelease.addToRelease(rawData: cosign.getPublicKey(), underName: "cosign.pub") } + } +} - ko.loginToRegistry(registry: registry) - image = ko.buildContainer(tags: tags, registry: registry) - cosign.sign(image) +String createAndPublishContainer(Context ctx, String registry) { + def ko = load(".ci/jenkins/tools/ko.groovy") + ko.install() + def cosign = load(".ci/jenkins/tools/cosign.groovy") + cosign.install("latest") + + List tags = [ctx.version] + if (isFinal(ctx)) { + tags << "latest" } + + ko.loginToRegistry(registry: registry) + image = ko.buildContainer(tags: tags, registry: registry) + cosign.sign(image) + } void signWinBinaries(Map args = [source: null, version: null, destDir: null, projectName: null]) {