Skip to content

Commit

Permalink
fix: prevent attempt of double publishing of cosign.pub
Browse files Browse the repository at this point in the history
  • Loading branch information
jskelin committed Nov 21, 2024
1 parent 3ca846a commit 34d548f
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions .ci/releasePipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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"]) {
Expand Down Expand Up @@ -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<String> 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<String> 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]) {
Expand Down

0 comments on commit 34d548f

Please sign in to comment.