forked from gabrielfalcao/HTTPretty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.release
executable file
·69 lines (59 loc) · 2.22 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
#!/bin/bash
declare newversion
declare current_version
declare sure
current_version="$(grep -E version ./httpretty/version.py | sed 's,version *= *.\(\([0-9]*[.]*\)\{3\,4\}\).,\1,g')"
echo -en "The current version is \033[1;33m$current_version\033[0m, type a new one\n\033[1;32mnew version:\033[0m "
read -r newversion
function find_files () {
for name in $(find . -name 'README.rst' -or -name version.py -or -name conf.py | grep -v '\(\.venv\|build\)[/]'); do
echo "${name}"
done
}
function update_files (){
find_files | xargs gsed -i "s,$current_version,$newversion,g"
}
function revert_files (){
find_files | xargs gsed -i "s,$newversion,$current_version,g"
}
echo -en "\033[A\033[A\rI will make a new commit named \033[1;33m'New release $newversion'\033[0m\n"
echo -en "Are you sure? [\033[1;32myes\033[0m or \033[1;31mno\033[0m]\n"
read -r sure
if [ "${sure}" == "yes" ]; then
echo "updating relevant files with new version..."
if update_files; then
echo "committing and pushing changes..."
echo -en "New release: \033[1;32m$newversion\033[0m\n"
if git add -f $(find_files); then
if git commit $(find_files) -m "New release: $newversion"; then
if git push; then
echo "creating tag ${newversion}..."
if git tag "${newversion}"; then
echo "pushing tag ${newversion}..."
git push --tags
else
echo "failed to create tag ${newversion}"
echo "you might want to revert the last commit and check what happened"
exit 1
fi
else
echo "failed to push, skipping release and reverting changes"
revert_files
exit 1
fi
else
echo "failed to commit, skipping release and reverting changes"
revert_files
exit 1
fi
else
echo "no files to git add, skipping release"
exit 1
fi;
else
echo "no files were updated, skipping release"
exit 1
fi
else
echo "kthankxbye"
fi