2019-07-03 09:00:34 -05:00
|
|
|
#!/usr/bin/env bash
|
2018-05-18 04:09:06 -05:00
|
|
|
|
|
|
|
# abort if we get any error
|
|
|
|
set -e
|
|
|
|
|
|
|
|
_tag=$1
|
|
|
|
_branch="$(git rev-parse --abbrev-ref HEAD)"
|
|
|
|
|
2019-07-23 05:12:33 -05:00
|
|
|
if [ "${_tag}" == "" ]; then
|
2018-05-18 04:09:06 -05:00
|
|
|
echo "Missing version param. ex './scripts/tag_release.sh v5.1.1'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-07-23 05:12:33 -05:00
|
|
|
if [ "${_branch}" == "master" ]; then
|
2018-05-18 04:09:06 -05:00
|
|
|
echo "you cannot tag releases from the master branch"
|
|
|
|
echo "please checkout the release branch"
|
|
|
|
echo "ex 'git checkout v5.1.x'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# always make sure to pull latest changes from origin
|
|
|
|
echo "pulling latest changes from ${_branch}"
|
2019-07-23 05:12:33 -05:00
|
|
|
git pull origin "${_branch}"
|
2018-05-18 04:09:06 -05:00
|
|
|
|
2019-07-23 05:12:33 -05:00
|
|
|
# create signed tag for latest commit
|
2018-05-18 04:09:06 -05:00
|
|
|
git tag -s "${_tag}" -m "release ${_tag}"
|
|
|
|
|
|
|
|
# verify the signed tag
|
|
|
|
git tag -v "${_tag}"
|
|
|
|
|
|
|
|
echo "Make sure the tag is signed as expected"
|
|
|
|
echo "press [y] to push the tags"
|
|
|
|
|
2019-07-23 05:12:33 -05:00
|
|
|
read -n -r 1 confirm
|
2018-05-18 04:09:06 -05:00
|
|
|
|
2019-07-03 09:00:34 -05:00
|
|
|
if [ "${confirm}" == "y" ]; then
|
2018-05-18 04:09:06 -05:00
|
|
|
git push origin "${_branch}" --tags
|
2019-07-03 09:00:34 -05:00
|
|
|
else
|
|
|
|
git tag -d "${_tag}"
|
2018-05-18 04:09:06 -05:00
|
|
|
echo "Abort! "
|
|
|
|
fi
|