mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
With some modification to catch up with latest situation. Signed-off-by: spacewander <spacewanderlzx@gmail.com>
59 lines
1.1 KiB
Bash
Executable file
59 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
hook() {
|
|
local hook=.git/hooks/$1.sh
|
|
# compat without extname
|
|
if test ! -f $hook; then
|
|
hook=.git/hooks/$1
|
|
fi
|
|
|
|
if test -f $hook; then
|
|
echo "... $1"
|
|
shift
|
|
if test -x $hook; then
|
|
$hook "$@"
|
|
else
|
|
. $hook "$@"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
if test $# -gt 0; then
|
|
version=$1
|
|
shift #remove version from arguments list
|
|
remote=''
|
|
hook_args="$version"
|
|
|
|
# check for flags
|
|
while test $# != 0
|
|
do
|
|
case "$1" in
|
|
-c) need_changelog=true;;
|
|
-r) remote=$2; shift ;;
|
|
-m) msg=$2; shift ;;
|
|
--) shift; hook_args="$hook_args $*"; break;;
|
|
*) usage ;;
|
|
esac
|
|
shift
|
|
done
|
|
if [ -z "$msg" ]; then
|
|
msg="Release ${version}"
|
|
fi
|
|
|
|
# shellcheck disable=SC2086
|
|
hook pre-release $hook_args
|
|
echo "... releasing $version"
|
|
if [ "$need_changelog" = true ]; then
|
|
git-changelog -t "$version"
|
|
fi
|
|
git commit -a -m "$msg"
|
|
# shellcheck disable=SC2086
|
|
git tag $version -a -m "$msg" \
|
|
&& git push $remote \
|
|
&& git push $remote --tags \
|
|
&& hook post-release $hook_args \
|
|
&& echo "... complete"
|
|
else
|
|
echo "tag required" 1>&2 && exit 1
|
|
fi
|