Last active
August 29, 2015 14:21
-
-
Save mtinsley/9977fb3211f43e71a32a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# The following demonstrates how to add build numbers to your project. | |
# This script can be added to your .git/hooks/pre-commit file. Alternatively | |
# you can add it as a separate shell script and call it from your pre-commit | |
# file. | |
# Fetch and increment the build number | |
buildnumber=`git rev-list HEAD --count` | |
((buildnumber++)) | |
# Write the build number to a file | |
echo $buildnumber > build | |
# Update a PHP class constant with the build number | |
sed -i "s/const BUILD.*/const BUILD = $buildnumber;/" Class.php>/dev/null 2>&1 | |
# Add the modified files | |
git add build | |
git add Class.php | |
echo "Build Number: $buildnumber" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment