diff --git a/pkg/recipe/git.go b/pkg/recipe/git.go index e2f0982d..4b0ffd2a 100644 --- a/pkg/recipe/git.go +++ b/pkg/recipe/git.go @@ -4,11 +4,13 @@ import ( "fmt" "os" "slices" + "sort" "strings" "coopcloud.tech/abra/pkg/formatter" gitPkg "coopcloud.tech/abra/pkg/git" "coopcloud.tech/abra/pkg/log" + "coopcloud.tech/tagcmp" "github.com/distribution/reference" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" @@ -345,6 +347,18 @@ func (r Recipe) Tags() ([]string, error) { return tags, err } + sort.Slice(tags, func(i, j int) bool { + version1, err := tagcmp.Parse(tags[i]) + if err != nil { + return false + } + version2, err := tagcmp.Parse(tags[j]) + if err != nil { + return false + } + return version1.IsLessThan(version2) + }) + log.Debugf("detected %s as tags for recipe %s", strings.Join(tags, ", "), r.Name) return tags, nil