Skip to content

Instantly share code, notes, and snippets.

@grepper
Created March 21, 2015 03:58
Show Gist options
  • Select an option

  • Save grepper/6f99cb666fb23dec813e to your computer and use it in GitHub Desktop.

Select an option

Save grepper/6f99cb666fb23dec813e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# .git/hooks/post-commit
githome="/home/robert/git/projects/tovid"
cd "$githome"
# only run when we are on master branch
# a release branch will have the version hard-coded
Status=$(git status | awk '{ print $NF ; exit }')
[[ $Status == "master" ]] || exit 0
Setup="$githome/setup.py"
Tag=$(git describe --tags $(git rev-list --tags --max-count=1))
Sha=$(git describe --always)
Version=$(sed -n "s/_last_release = '\(.*\)'/\1/p" "$githome/setup.py")
Version=${Version}+${Sha}
# change _tovid_version in setup.py
sed -i "s/^_tovid_version.*/_tovid_version = '$Version'/" "$Setup"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment