Comparison operations for image tags
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Renovate Bot c61e2ebb71 chore(deps): update golang docker tag to v1.19 4 months ago
.drone.yml chore(deps): update golang docker tag to v1.19 4 months ago
.gitignore feat: add pin compatibility check 1 year ago
LICENSE Add license 1 year ago
Makefile feat: setup CI with drone 1 year ago fix: lol fix link [ci skip] 1 year ago
go.mod Init 1 year ago docs: add IsUpgradeCompatible 1 year ago
renovate.json chore(deps): add renovate.json 1 year ago
tagcmp.go feat: add pin compatibility check 1 year ago
tagcmp_test.go test: pin compatiliby check tests 1 year ago


Build Status Go Report Card

Comparison operations for image tags. Because registries aren't doing this for us 🙄

This library is helpful if you're aiming to use only "stable" and "semver-like" tags and want to be able to do things like compare them, find which tags are more recent, sort them and other types of comparisons. This is a best-effort implementation which follows the wisdom of Renovate.

Docker doesn't really have versioning, instead it supports "tags" and these are usually used by Docker image authors as a form of versioning ... It's pretty "wild west" for tagging and not always compliant with SemVer.

The Renovate implementation, which allows image tags to be automatically upgraded, is the only show in town, apparently. This library follows that implementation quite closely.


package main

import (


func main() {
	rawTags := []string{

	tag, err := tagcmp.Parse("1.14.0-rootless")
	if err != nil {

	var compatible []tagcmp.Tag
	for _, rawTag := range rawTags {
		parsed, _ := tagcmp.Parse(rawTag) // skips unsupported tags
		if tag.IsCompatible(parsed) {
			compatible = append(compatible, parsed)




[1.14.0-rootless 1.14.1-rootless 1.14.2-rootless]


Types of versions supported

// semver

// semver with 'v'

// semver with suffix

// semver with sufix and 'v'

// semver with multiple suffix values

// semver with multiple suffix values and 'v'

Types of versions not supported

Please note, we could support some of these versions if people really need them to be supported. Some tags are using a unique format which we could support by implementing a very specific parser for (e.g. ParseMinioTag, ParseZncTag). For now, this library tries to provide a Parse function which handles more general cases. Please open an issue, change sets are welcome.

// empty

// patametrized

// commit hash like

// numeric

// not semver

// prerelease

// multiple versions

// tz based

// only text

// multiple - delimters



Who's using it?