Image Semantic Versioning tagging

To make it related to Docker you will need to make sure you use the right tags on the images in case you want to support multiple versions. When the build is triggered by v2.3.5 when there is also 2.4.3, you can only push “:2.3.5” and “:2.3” but not “:2”. Example:

docker tag myimage:$CI_COMMIT_HASH myimage:2.3.5
docker tag myimage:$CI_COMMIT_HASH myimage:2.3

docker push myimage:$CI_COMMIT_HASH myimage:2.3.5
docker push myimage:$CI_COMMIT_HASH myimage:2.3

If you push myimage:2", you override the latest v2 image which would be “myimage:2.4.3”.

For that I once used a python library and I believe it was called dcd, but I can’t find it now. Later I realized I wanted more freedom in terms of what I can do before pushing and I didn’t want to use a python lib in bash, so I made my own solution in bash.

The “dcdCommandGen” generates the commands similar to the old dcd library and I call my replacement function “deployCommandGen”. which generates the final docker commands using other functions.

Note that it is still not a library that you can easily use. I just thought if you understand bash, it could give you an idea and you can also copy parts of the script and use as long as you don’t claim you wrote that. A link in the sourcecode to the original repository is enough which can help you too, to remember where it came from :slight_smile: In that script I also have solutions to determine what are the latest major, minor and patch versions based on semantic git version tags.