This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
release
executable file
·69 lines (59 loc) · 1.96 KB
/
release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
main() {
case "$1" in
f|finish|finalise)
action="${2:-release}"
finish_release ;;
h|hot|hotfix)
newver="$2" action="hotfix"
bump_version ;;
*)
newver="$1" action="release"
git flow release start "$newver" && bump_version ;;
esac
}
bump_version() {
echo
echo
echo "+----------------+"
echo "| UPDATING FILES |"
echo "+----------------+"
echo
oldver="$(grep __version__ src/__init__.py | sed 's/.*"\(.*\)\"/\1/')"
search="${oldver}\(...develop\)"
today=$(date "+%Y-%m-%d")
echo -n "bumping version to ${newver}... "
sed -i "s/${oldver}/${newver}/" src/__init__.py && echo "done" || exit 1
# 1. Insert header for new version's changes
# 2. Find the [Unreleased] link and add the new release diff below it
# 3. Update the previous version number in the Unreleased link
echo -n "Updating changelog... "
sed -i -e "s/^\(## \[Unreleased\]\)$/\1\n\n\n## [${newver}] - ${today}/" \
-e "s/ \(.*\/\)${search}/&\n[${newver}]: \1${oldver}...${newver}/" \
-e "s/${search}/${newver}\1/" CHANGELOG.md && echo "Done" || exit 1
echo
git add CHANGELOG.md src/__init__.py
git commit -m "Bump version to ${newver}"
echo
echo "Now's your chance to make more changes. If there are none, press y."
read -rp "Finalise release [yN]? " autopush
if [ ! "$autopush" = "y" ]; then
echo
echo "Aborting to make more changes. When ready, run"
echo "'gf release finish ${newver}' then push all branches"
echo "and tags before finalising with './release finish'"
exit 0
fi
finish_release
}
finish_release() {
echo
echo
echo "+--------------------+"
echo "| FINALISING RELEASE |"
echo "+--------------------+"
echo
git flow "$action" finish "${newver}" \
&& git push origin --all && git push origin --tags
}
main "$@"