bump.sh
これが私が呼び出す私のスクリプトであり、それに更新するための新しいバージョンを提供します。残りのプロセスのほとんどを処理します。
me@server:~/git_repos/# ./bump.sh git_project
Enter new version (Current 1.0.5): 1.0.6
Are you sure you want to release version 1.0.6? (y|n): y
Switched to a new branch 'release-1.0.6'
Switched to branch 'master'
Deleted branch release-1.0.6 (was 4abcd98e).
If you need to undo this last commit, abort now and run:
git reset --hard HEAD~1
git tag -d 1.0.6
Do you want to push this to the origin server (THIS IS NOT EASILY UNDONE)? (y|n): y
Password for 'https://user@bitbucket.org':
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 704 bytes, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: bb/acl: user is allowed. accepted payload.
To https://remote_repository.../.git
ffffffab..010101ab master -> master
Finished merging.
bump.sh
if [ ! -d "$1" ]; then
echo "Must pass git directory as the first argument."
exit 2;
fi
cd $1
echo -e "Enter new version (Current `git describe --abbrev=0 --tags`): \c "
while read ver; do
if ([[ ! -z "$ver" ]]) && ([ "$ver" == "`echo $ver | grep "^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$"`" ])
then
break
else
echo " Version entered ($ver) was not formatted properly."
echo -e "Enter new version (Current `git describe --abbrev=0 --tags`): \c "
fi
done
echo -e "Are you sure you want to release version $ver? (y|n): \c "
read confirm
if([ $confirm == "y" ]) then
git checkout -b release-$ver develop
git checkout master
result=`git merge --no-ff release-$ver`
if([ "$result" == "`echo $result | grep "^Already up-to-date\."`" ]) then
git branch -D release-$ver
echo "The branch is already up to date. Aborting version bump.";
exit 3;
else
git tag -a $ver -m "Used bump script."
git branch -D release-$ver
echo ""
echo "If you need to undo this last commit, abort now and run:"
echo " git reset --hard HEAD~1"
echo " git tag -d $ver"
echo ""
echo -e "Push this change to the origin server and merge back into the develop branch? (y|n): \c "
read confirm
if([ $confirm == "y" ]) then
git push origin master
git checkout develop
git merge master
fi
echo "Finished merging."
exit 1;
fi
else
echo "Aborted the version bump."
exit 1;
fi