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.
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?
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 In that script I also have solutions to determine what are the latest major, minor and patch versions based on semantic git version tags.
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.
@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.