I am using a pre-push
hook that copies some files around and uses grunt bump
to up the version number on my package prior to zipping it up. This all happens on the master
branch and the assumption is that because it's a push on master
, it's worthy of a patch version increase and zips up my Chrome extension to include all the necessary files.
The issue I am running into is that the version is modified too late for it to be committed for the hook to include it in the push, thus my next commit is always 1 patch version behind what is actually tagged.
What solution do I have here? This is a single-user project so I am not worried too much about going against how the hook is intended to be used. Would an option be to commit and a sub push, and then return non-zero from this hook to prevent the push from happening?
#!/bin/sh
PATH=$PATH:/usr/local/bin:/usr/local/sbin
BRANCH="$1"
EXTENSION_PATH=./extension
SCRIPT_PATH=$EXTENSION_PATH/script/
if [ "$branch" == "master" ]
then
# remove the existing script folder; we'll just re-populate it
echo "Removing existing scripts..."
rm -rf $EXTENSION_PATH/script
echo "Making target directory: $SCRIPT_PATH"
mkdir $SCRIPT_PATH
echo "Copying script files..."
cp config.js $SCRIPT_PATH
cp supportportal.js $SCRIPT_PATH
cp -r ./scripts/ $SCRIPT_PATH/scripts/
# bump the version
grunt bump
# commit changes and push here
# >>>
# if on a tag, append that to the filename
VERSION=$(git describe --tags --always)
# get name of the most top folder of git repo directory,
# combine with revision tail
OUTPUT=extension-$VERSION.zip
# building archive
zip -r -X $OUTPUT $EXTENSION_PATH
echo "Done!";
fi
exit 0 #exit 1 instead of 0 to cancel original push?