-
Notifications
You must be signed in to change notification settings - Fork 1
/
.release
executable file
·37 lines (30 loc) · 1.08 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
#!/bin/bash
current_version=$(cat .markment.yml | egrep version | sed 's,^[^:]*: *,,g')
printf "The current version is \033[1;33m$current_version\033[0m, type the new version:\n"
read newversion
find_files (){
egrep -I --exclude-dir=.git -R $current_version . | egrep -v '[.].*[.]log' | cut -d: -f1 | xargs
}
update_files (){
for file in `find_files`;
do
printf "Changing file \033[33m$file\033[0m... ";
perl -pi -e "s,$current_version,$newversion,g" $file;
printf "\rChanged file \033[32m$file\033[0m: OK\n";
done;
}
abort () {
printf "\033[31m$@\033[0m\n"
exit 1;
}
printf "\033[A\033[A\rI will make a new commit named \033[1;33m'New release $newversion'\033[0m\n"
printf "Are you sure? [\033[1;32myes\033[0m or \033[1;31mno\033[0m]\n"
read sure
git tag | egrep "$newversion" 2>&1> /dev/null && abort "There is a tag for \033[33m$newversion\033[0m already"
if [ $sure == "yes" ]; then
update_files
printf "New release: \033[1;32m$newversion\033[0m\n"
git add .
git commit -am "New release: $newversion"
git tag $newversion
fi;