Debian Codegraph @

.release

raw symbols SCIP
1 #!/bin/bash
2
3 declare newversion
4 declare current_version
5 declare sure
6
7
8 current_version="$(grep -E version ./sure/version.py | sed 's,version *= *.\(\([0-9]*[.]*\)\{3\,4\}\).,\1,g')"
9 echo -en "The current version is \033[1;33m$current_version\033[0m, type a new one\n\033[1;32mnew version:\033[0m "
10 read -r newversion
11
12
13 function find_files () {
14 for name in $(find . -name 'README.rst' -or -name version.py -or -name conf.py | grep -v '\(\.venv\|build\)[/]'); do
15 echo "${name}"
16 done
17
18 }
19
20 function update_files (){
21 find_files | xargs gsed -i "s,$current_version,$newversion,g"
22 }
23 function revert_files (){
24 find_files | xargs gsed -i "s,$newversion,$current_version,g"
25 }
26
27 echo -en "\033[A\033[A\rI will make a new commit named \033[1;33m'New release $newversion'\033[0m\n"
28 echo -en "Are you sure? [\033[1;32myes\033[0m or \033[1;31mno\033[0m]\n"
29 read -r sure
30
31
32 if [ "${sure}" == "yes" ]; then
33 echo "updating relevant files with new version..."
34 if update_files; then
35 echo "committing and pushing changes..."
36 echo -en "New release: \033[1;32m$newversion\033[0m\n"
37 if git add -f $(find_files); then
38 if git commit $(find_files) -m "New release: $newversion"; then
39 if git push; then
40 echo "creating tag ${newversion}..."
41 if git tag "v${newversion}"; then
42 echo "pushing tag ${newversion}..."
43 git push --tags
44 else
45 echo "failed to create tag ${newversion}"
46 echo "you might want to revert the last commit and check what happened"
47 exit 1
48 fi
49 else
50 echo "failed to push, skipping release and reverting changes"
51 revert_files
52 exit 1
53 fi
54 else
55 echo "failed to commit, skipping release and reverting changes"
56 revert_files
57 exit 1
58 fi
59 else
60 echo "no files to git add, skipping release"
61 exit 1
62 fi;
63 else
64 echo "no files were updated, skipping release"
65 exit 1
66 fi
67 else
68 echo "kthankxbye"
69 fi