DEV Community

Fran Iglesias
Fran Iglesias

Posted on • Originally published at on

Automate semantic versioning in git

I've just wrote a little command line tool to automate tags for semantic versioning in git.

You can see and download in the github repository, where you'll find full documentation.

versiontag looks for the last version tag in your project and updates it.

When you are ready for tagging, you only has to invoke versiontag with the version level you want to update. And that's all. It would show you the current version, the new one, and will ask you for confirmation to add and to push it to the remote.

This is an example from the versioning of versiontag , in which you can see all steps and details:

➜ versiontag git:(master) ./versiontag patch 'Add License'
Current version : v1.0.1
New tag :         v1.0.2
Do you agree? ([y]es or [N]o): y

Executing git tag -a v1.0.2 -m Add License (patch version) ...

Tag v1.0.2 was created in local repository.

Push it:

    git push origin v1.0.2

Delete tag:

    git tag -d v1.0.2

Do you want to push this tag right now? ([y]es or [N]o): y

Executing git push origin v1.0.2 ...

Counting objects: 1, done.
Writing objects: 100% (1/1), 179 bytes | 179.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0)
 * [new tag] v1.0.2 -> v1.0.2

Ideas and improvements will be welcome (specially get the last version tag from the remote and discriminate tags that are not version related).

HTH :-)

Top comments (5)

oleksandrkucherenko profile image
pkristiancz profile image
Patrik Kristian

Hey there, it actually got my attention and it looks interesting. I readed readme and code itself. I have few quick suggestions to improve.

  • simple instalation (see my )
  • allow empty message
  • add push param (something like —push, -p) to push without asking and what about do not asking if push?
  • when wanting confirmation of new tag, just proceed when enter is pressed or take “y” as default option. take “n” for no ( or ctrl+c can be used)
  • allow bypass confirmation by param —yes or -y
  • i will try to treat it as regular linux utility, so using —params will be nice.
franiglesias profile image
Fran Iglesias

Thank you for the suggestions, Patrik,

The over-confirmation issue ;-) comes from the fact that currently I cannot be certain about what kind/format of tag the tool will retrieve from git describe, so I decided to ask before proceed. I think improving the tag detection from the beginning will help.

The idea of a --push or --force option is something I was starting to think about.

Well, this is a pet project of mine to learn something about shell scripting and git, so all suggestions are more than welcome. :-)

pkristiancz profile image
Patrik Kristian

I personally love git and bash, and making tool for that is something, what i highly support. I think, once it is done, it will be nice package to have. I think, when you are your own user, project is good to go.

If you will be interested, it will be nice to "exchange" improve our bash-git repos. :)
If you want, please look at my, send PR, open issue, whatever. :)

Happy bashing! :)

Thread Thread
franiglesias profile image
Fran Iglesias

Sure, I'll do. :-)