From 1bbe2adaf02e6d85e31ff481a764f32e36a175e4 Mon Sep 17 00:00:00 2001 From: Kim Christensen Date: Tue, 2 Jul 2024 22:42:43 +0200 Subject: [PATCH] Fix canary build of the server image Building and publishing the server image during a canary build, did not use the canary tag, instead it used the version of the build, e.g., v1.1.0-7-gd0387ecb. It also means that on each canary build a new tag is used when publishing the image. By checking if we are doing a release of a tagged version or a canary build we can use the correct tag. Signed-off-by: Kim Christensen --- magefile.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/magefile.go b/magefile.go index d902a4838..1b323c975 100644 --- a/magefile.go +++ b/magefile.go @@ -421,11 +421,22 @@ func pushImagesTo(registry string, info releases.GitMetadata) { func PublishServerMultiArchImages() { registry := getRegistry() info := releases.LoadMetadata() - buildAndPushServerMultiArch(registry, info) + + if info.IsTaggedRelease { + buildAndPushServerMultiArch(registry, info.Version) + } else { + fmt.Println("Skipping server image publish for not tagged release", info.Version) + } + + if info.ShouldPublishPermalink() { + buildAndPushServerMultiArch(registry, info.Permalink) + } else { + fmt.Println("Skipping server image publish for permalink", info.Permalink) + } } -func buildAndPushServerMultiArch(registry string, info releases.GitMetadata) { - img := fmt.Sprintf("%s/server:%s", registry, info.Version) +func buildAndPushServerMultiArch(registry string, tag string) { + img := fmt.Sprintf("%s/server:%s", registry, tag) must.RunV("docker", "buildx", "create", "--use") must.RunV("docker", "buildx", "bake", "-f", "docker-bake.json", "--push", "--set", "server.tags="+img, "server") }