diff --git a/circleci/docker.go b/circleci/docker.go index 8c70676d..641665e2 100644 --- a/circleci/docker.go +++ b/circleci/docker.go @@ -113,7 +113,7 @@ func findNewestDockerVersion(currentVersion string, parameters *map[string]*yaml cache[currentVersion] = currentTag return imageName, currentTag, currentTag } - newVersion := newest.Original() + newVersion := TrimSemver(currentTag, newest.Original()) cache[currentVersion] = newVersion return imageName, currentTag, newVersion } diff --git a/circleci/orb.go b/circleci/orb.go index 0e62858e..3f0cd06c 100644 --- a/circleci/orb.go +++ b/circleci/orb.go @@ -67,11 +67,12 @@ func findNewestOrbVersion(currentVersion string, parameters *map[string]*yaml.No return orbName, currentTag, currentTag } - if len(orbInfo.Orb.HighestVersion) == 0 { + if len(orbInfo.Orb.HighestVersion) == 0 || strings.HasPrefix(orbInfo.Orb.HighestVersion, currentTag) { cache[currentVersion] = currentTag return orbName, currentTag, currentTag } - cache[currentVersion] = orbInfo.Orb.HighestVersion - return orbName, currentTag, orbInfo.Orb.HighestVersion + newVersion := TrimSemver(currentTag, orbInfo.Orb.HighestVersion) + cache[currentVersion] = newVersion + return orbName, currentTag, newVersion } diff --git a/circleci/update.go b/circleci/update.go index 2e6dda47..a54af753 100644 --- a/circleci/update.go +++ b/circleci/update.go @@ -170,3 +170,12 @@ func ExtractParameterName(param string) string { } return "" } + +func TrimSemver(currentTag, newTag string) string { + currentSplit := strings.Split(currentTag, ".") + newSplit := strings.Split(newTag, ".") + if len(currentSplit) > len(newSplit) { + return newTag + } + return strings.Join(newSplit[0:len(currentSplit)], ".") +}