peritus / bumpversion

Version-bump your software with a single command
https://pypi.python.org/pypi/bumpversion
MIT License
1.5k stars 148 forks source link

Hooks #137

Closed jdeniau closed 7 years ago

jdeniau commented 8 years ago

Hi,

Is it possible to trigger pre/post-bumpversion scripts ?

Let me explain:

For a javascript module, you want to build a dist version of your module, so you need to run babel or somethings like that. It would be great if we could just run these sorts of command after or before bumpversion.

Thank you

peritus commented 8 years ago

Yes, create a shell script like this:

./pre-bump.sh
bumpversion bar
./post-bump.sh

.. would that work for you ?

jdeniau commented 8 years ago

The fact is that my team (and I) are pretty used to the bumpversion command, So I think that the power of habits will make us do wrong things.

Another solution could be to make an alias of bumpversion, which does that, but maybe a hook system in the bumpversion could make sense, don't you think ?

This way you can add hooks like PRE_GIT_COMMIT, POST_GIT_TAG, or things like that.

It may be a little complex for a small profit though.

joelfrederico commented 8 years ago

I was hoping for a bumpversion hook for autotools. When you update the version number, you need to run autoreconf, which propagates the version number to all the various configure files so that configuring creates the proper version number. I'd rather not go behind autoreconf's back and try to do its job for it.

This mean's I'd like bumpversion to:

  1. Update the files I want with the proper version number (in my case, configure.ac).
  2. Call a script of my choice. (In my case, autoreconf -fiv, which propagates the version number to the appropriate places and creates a git commit.)
  3. Create a commit and tag for a new version, etc.

My two bits' worth. I could theoretically write a script to do this: call bumpversion --no-commit --no-tag, run autoreconf -fiv, then bumpversion. But a hook system would make that easier, just set an option for the autoreconf -fiv hook and let bumpversion handle things.

jdeniau commented 8 years ago

@peritus I just re-read your comments and I think I missunderstand it :)

Shell scripts would work fine, but I think just a "command" in the .bumpversion.cfg file would be more flexible

something like:

hooks:
    pre-bump: gulp
    post-bump: ./post-bump.sh
peritus commented 8 years ago

@jdeniau Sorry, not going to happen. Bumpversion won't be your new Makefile :)

diegoquintanav commented 5 years ago

I second this request. In my case, I would like to git add an updated CHANGELOG.md that I generate with https://github.com/vaab/gitchangelog, besides bumpversion:file and .bumbversion.cfg.

The nice way would be through hooks, but without them I'm forced to do something like this

#!/bin/sh

# fetch new version using bumpversion
CURRENT_VERSION=$(bumpversion --dry-run --allow-dirty --list patch | grep '^current_version' | sed -r s,"^.*=",,)
NEW_VERSION=$(bumpversion --dry-run --allow-dirty --list patch | grep '^new_version' | sed -r s,"^.*=",,)

# generate changelog
# see https://github.com/vaab/gitchangelog/issues/94
gitchangelog | sed -r "s/%%unreleased_version%%/${NEW_VERSION}/g" > CHANGELOG.md

# generate new revisions
bumpversion --dry-run --allow-dirty --verbose --no-commit patch

# stage changes
git add CHANGELOG.md VERSION .bumpversion.cfg

# commit message
# here, `new:` `dev:` and `!minor` are `gitchangelog` syntax
git commit -m "new: dev: bump version ${CURRENT_VERSION} to ${NEW_VERSION} !minor" 

# git tag new revision
git tag -a "v${NEW_VERSION}" -m "bump version v${NEW_VERSION} from v${CURRENT_VERSION}"

So, although this works, here I'm using bumpversion only as a revision parser. I like to think that bumpversion has more potential. I don't see how this predates a Makefile.