Skip to content

Instantly share code, notes, and snippets.

@zombor
Created March 11, 2011 04:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save zombor/865461 to your computer and use it in GitHub Desktop.
Save zombor/865461 to your computer and use it in GitHub Desktop.
Kohana Release Script - Bash script to do a kohana release from git.
#!/bin/bash
MAJOR_VERSION=$1
MINOR_VERSION=$2
if [ $# -lt 2 ]
then
echo "Usage: $0 <MAJOR-VERSION> <MINOR-VERSION>"
exit
fi
if ( [ ${#MAJOR_VERSION} -ge ${#MINOR_VERSION} ] || [ "$MAJOR_VERSION" != "${MINOR_VERSION:0:${#MAJOR_VERSION}}" ] )
then
echo "MAJOR-VERSION must be a prefix of MINOR-VERSION"
exit 1
fi
function update_cwd
{
git fetch
git checkout $MAJOR_VERSION/master
git submodule update
git merge origin/$MAJOR_VERSION/master
git checkout $MAJOR_VERSION/develop
git submodule update
git merge origin/$MAJOR_VERSION/develop
}
echo "Are you really prepared to release? This will create PRODUCTION RELEASE! (Y/N)"
read ready
case "$ready" in
Y*|y*)
# Continue!
;;
*)
echo "Aborted!"
exit 1
;;
esac
# Make sure we are completely up to date
update_cwd
# Start the release for kohana/kohana
git flow release start $MINOR_VERSION
# Do modules/*
find modules/* -maxdepth 0 -type d | while read -r dir
do
cd $dir
# Make sure we are completely up to date
update_cwd
# Start the release branch
git flow release start $MINOR_VERSION
echo "Please make sure that everything in ${dir} is ready for release, then hit <enter>:"
read ready
git flow release finish $MINOR_VERSION
# Push the changes
#git push origin-push ${MAJOR_VERSION}/develop
#git push origin-push ${MAJOR_VERSION}/master
cd -
git add $dir
done
# Do system/
find system -maxdepth 0 -type d | while read -r dir
do
cd $dir
# Make sure we are completely up to date
update_cwd
# Start the release branch
git flow release start $MINOR_VERSION
echo "Please make sure that everything in ${dir} is ready for release, then hit <enter>:"
read ready
git flow release finish $MINOR_VERSION
# Push the changes
#git push origin-push ${MAJOR_VERSION}/develop
#git push origin-push ${MAJOR_VERSION}/master
cd -
git add $dir
done
git commit -m "tracking submodules for ${MINOR_VERSION}"
git flow release finish $MINOR_VERSION
# Push the changes
#git push origin ${MAJOR_VERSION}/develop
#git push origin ${MAJOR_VERSION}/master
@cbandy
Copy link

cbandy commented Mar 11, 2011

Should MAJOR_VERSION be a prefix of MINOR_VERSION?

if ( [ ${#MAJOR_VERSION} -ge ${#MINOR_VERSION} ] || [ "$MAJOR_VERSION" != "${MINOR_VERSION:0:${#MAJOR_VERSION}}" ] )
then
    echo "MAJOR-VERSION must be a prefix of MINOR-VERSION"
    exit 1
fi

@shadowhand
Copy link

For checking read ready:

case "$ready" in
    y*|Y*)
        # Continue!
        ;;
    *)
        echo "Aborted!"
        exit 1
        ;;
esac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment