Automatic version number?

Is there any option to set the app version number automatically? Because right now I have to set it manually everytime I am releasing new one

Write a script that replaces the version in config.xml automatically and then calls ionic cordova prepare.

could you tell me how to do that?