Skip to content

Instantly share code, notes, and snippets.

@simonda86
Created November 7, 2013 19:18
Show Gist options
  • Save simonda86/7360328 to your computer and use it in GitHub Desktop.
Save simonda86/7360328 to your computer and use it in GitHub Desktop.
Watch a file for updates to version number and then automatically adds a git tag
#!/bin/bash
# Options
file="style.css"
prefix="Version:"
# Do not edit below
tag=$(git tag | tail -1)
version=$(grep -F $prefix $file)
version=${version##*:}
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }'; }
if [ $(version $version) -gt $(version $tag) ]; then
# Tag git with the new version number
git tag $version
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment