Image Semantic Versioning tagging

Hi Team,

I am building docker images using Gitlab CI/CD and tagging as CI_COMMIT_SHA but, i want to achieve semantic versioning for docker images and for every commit to the ref branch need to increment patch and minor version based on commit branch.

Need your support to achieve that.

In short: you need someone to share their Gitlab CI/CD Job that creates version numbers based on the git metadata, so you can use it to generate versions that you want to use as image tags.

Just out of curiosity: wouldn`t this question be more suited for a Gitlab CI/CD related forum?

Even though, this is not what you are looking for, you might want to read Meaningful Versions with Continuous Everything.

1 Like

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.

1 Like

Hi @rimelek, Thank you.

I am Trying to execute your code but in Gitlab CI/CD Process I am getting an error.
here is the screenshots.
image

As I wrote I shared the script to give some ideas. You will still have to try to search for the error messages. You can share if you find something and don’t understand. You got a pretty good error message, so there must be plenty of search results for that on Google. I guess you know it is a git repository so the second part of the message could be more important, but I would have to search for it as well so I leave it to you.

I found better solution for this. used node module it’s so pretty we can maintain a changelog.MD file as well.
however, thank you @rimelek you tried to support me. but your process will take longer time compared to node modules. close this thread.

Can you share the name of the node module? It could be useful for others as well if it is publicly available


@rimelek
As I shared the one idea. You will still have to try asking entire modules So, you can search about which node modules will help you to achieve that (semantic versioning) on Google.

I feel like your response intended to be a revange after my Google response, but I’m not sure why you think my question could be compared to yours. I don’t really care what the name of the module is as I wouldn’t use it and I’m pretty sure I can find anything I want, but if you ask on a public forum from the community, why would you keep it secret when you find the solution?

@rimelek don’t feel like that, I am not doing like that. But how much support I received from public form that much of support I can give. i don’t have any kind of feelings to share that. that’s why i gave any idea about modules so that other guys can search. them self can achieve their own way. so that we can boost up others. :slightly_smiling_face: