From 47f216af83bc83b9e76121810b8bfaa2f25ae747 Mon Sep 17 00:00:00 2001 From: Lev Vereshchagin Date: Fri, 17 Dec 2021 12:24:57 +0300 Subject: [PATCH] Parse and set short tags from git tag in bake file --- TODO.md | 4 ++-- docker-bake.hcl | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index 0a228490..af42a1a5 100644 --- a/TODO.md +++ b/TODO.md @@ -2,5 +2,5 @@ - [ ] Test with helm chart - [x] Play With Docker generation - [x] Custom app compose and dockerfile examples -- [ ] Add v13 v12 tags -- [ ] Use &\* feature of yaml to describe backends +- [x] Add v13 v12 tags +- [x] Use &\* feature of yaml to describe backends diff --git a/docker-bake.hcl b/docker-bake.hcl index 64744ed4..687d8503 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -43,8 +43,12 @@ group "default" { function "tag" { params = [repo, version] - # If `version` parameter is develop (development build) then use tag `latest` - result = ["${version}" == "develop" ? "${USERNAME}/${repo}:latest" : "${USERNAME}/${repo}:${version}"] + result = [ + # If `version` param is develop (development build) then use tag `latest` + "${version}" == "develop" ? "${USERNAME}/${repo}:latest" : "${USERNAME}/${repo}:${version}", + # Make short tag for major version if possible. For example, from v13.16.0 make v13. + can(regex("(v[0-9]+)[.]", "${version}")) ? "${USERNAME}/${repo}:${regex("(v[0-9]+)[.]", "${version}")[0]}" : "", + ] } target "default-args" {