Looking for a way automate the “bump version” with

2020-02-19 05:53发布

I have been using git flow for a couple of months and it has worked very well. I would like to automate the "bump version" operation.

The project is PHP and the footer.php has a token to replace with the current release tag. I am certain that with some awk'ing of git log and the PHP file everything should work out, but I assume someone has done this before...

Any ideas?

8条回答
爷、活的狠高调
2楼-- · 2020-02-19 06:20

You can automate the version bumping every commit. Here you can find it done using the shell script and the built-in git hook: https://github.com/addonszz/Galileo/tree/develop/githooks

The shell scrip to run is: https://github.com/evandrocoan/.versioning/blob/master/scripts/updateVersion.sh

The problem about automate every thing is how to know whether you are updating the Major, Minor, Patch or Build, when you are committing everything.

I mean, for build you could automate every development branch commit, as done in the above link.

The patch, you can hook every git flow hotfix finish. The above link just lacks to hook the hotfix finish to increment the patch version running: ./githooks/updateVersion.sh patch

But the minor and major there is no trick, they are all done within the feature finish release.

Obs

I found a solution to hooking the pre-hotfix-commits, it is on the question: How to pre-hook the gitflow hotfix finish?

查看更多
欢心
3楼-- · 2020-02-19 06:21

There's also bumpversion (more info at https://github.com/peritus/bumpversion) that aims to replace that sed magic.

Install with pip install bumpversion, tell it which files contain your version number and whether you want to commit and tag that. It's also highly configurable (with semantic versioning as default), so you can add a declarative config file of how to bump versions for this software project to your vcs of choice and others can also bump versions.

查看更多
登录 后发表回答