Skip to content

Commit

Permalink
ES-3193 bumps keep semver level (#470)
Browse files Browse the repository at this point in the history
* fix1

* Done?
  • Loading branch information
Andrei-Predoiu committed Jul 19, 2024
1 parent d814421 commit b76dc91
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion circleci/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 4 additions & 3 deletions circleci/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
9 changes: 9 additions & 0 deletions circleci/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)], ".")
}

0 comments on commit b76dc91

Please sign in to comment.