-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
release
executable file
·100 lines (84 loc) · 2.8 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
main() {
case "$1" in
a|aur)
update_aur ;;
f|finish|finalise)
action="${2:-release}"
newver="$(./nextshot -V | grep -oP 'v\K.*')"
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="$(./nextshot -V | awk '{ print $2 }')"
search="${oldver}\(...develop\)"
today=$(date "+%Y-%m-%d")
echo -n "Bumping version to ${newver}... "
sed -i "s/\(_VERSION=\)\".*\"$/\1\"${newver}\"/" src/main.bash && 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}...v${newver}/" \
-e "s/${search}/v${newver}\1/" CHANGELOG.md && echo "Done" || exit 1
echo -n "Updating PKGBUILD version... "
sed -i "s/^\(pkgver=\).*$/\1${newver}/" .aur/PKGBUILD && echo "Done" || exit 1
echo
git add src/main.bash CHANGELOG.md
git commit -m "Bump version to ${newver}"
echo
echo "Now's your chances 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 aur'"
exit 0
fi
finish_release
}
finish_release() {
echo
echo
echo "+--------------------+"
echo "| FINALISING RELEASE |"
echo "+--------------------+"
echo
git flow "$action" finish "${newver}" \
&& git push origin master && git push origin develop \
&& git push origin --tags \
&& update_aur
}
update_aur() {
echo
echo
echo "+-----------------------+"
echo "| PREPARING AUR PACKAGE |"
echo "+-----------------------+"
echo
cd .aur || exit 1
echo "Updating package checksums..."
updpkgsums && echo || exit 1
echo -n "Rebuilding .SRCINFO... "
makepkg --printsrcinfo > .SRCINFO && echo -e "Done\n" || exit 1
git add PKGBUILD .SRCINFO
git commit -m "Update to $(../nextshot -V | awk '{print $2}')" \
&& echo && git push && echo
echo "AUR repo updated! Current version as seen in AUR:"
yay -Ss nextshot
}
make && main "$@"