forked from PlanningBiblio/PlanningBiblio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo_minor_release.sh
executable file
·136 lines (97 loc) · 2.9 KB
/
do_minor_release.sh
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#! /bin/bash
#Documentation
usage() {
cat <<EOF
Do a minor Planno release
-h | --help
Show help
EOF
}
##
# Get input args
##
# Help
if [[ "$1" = "-h" || "$1" = "--help" ]]
then
usage
exit
fi
while [ $1 ]; do
case $1 in
* )
echo "Unknown arg $1"
usage
exit
esac
shift
done
# Get current release
from=$(grep 'version=' init/init.php | sed 's/\$version="\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/g')
# Create new release number
major=$(echo $from | sed 's/\([0-9]*\.[0-9]*\)\.\([0-9]*\)/\1/g')
minor=$(echo $from | sed 's/\([0-9]*\.[0-9]*\)\.\([0-9]*\)/\2/g')
minor=$(echo $minor | sed 's/^0*//')
minor="$(($minor + 1))"
minor=$(printf "%02d\n" $minor)
digit2=$(echo $from | sed 's/[0-9]*\.\([0-9]*\)\.[0-9]*/\1/g')
to=$major.$minor
echo -e "\e[0;33mReleasing from version $from to $to\e[0m\n"
echo -e "\e[0;33mDo you want to proceed ? [yes/no]\e[0m\n"
read proceed
proceed=$(echo $proceed | tr '[:upper:]' '[:lower:]');
if [[ $proceed != 'yes' && $proceed != 'y' ]]; then
echo "Nothing changed. Bye"
exit;
fi
# Update Changelog
date=$(date +%Y-%m-%d)
echo "*** Version $to ($date) ***" > ChangeLog.tmp
echo "" >> ChangeLog.tmp
cat ChangeLog.txt >> ChangeLog.tmp
mv ChangeLog.tmp ChangeLog.txt
vi ChangeLog.txt
sed -i "s/$from/$to/g" 'init/init.php'
sed -i "s/$from/$to/g" 'public/setup/db_data.php'
git diff
sed -i "/# MARKER/i\ \n\$v=\"$to\";\n\nif (version_compare(\$config['Version'], \$v) === -1) {\n\n\ \$sql[] = \"UPDATE \`{\$dbprefix}config\` SET \`valeur\`='\$v' WHERE \`nom\`='Version';\";\n}" 'public/setup/maj.php'
vi public/setup/maj.php +/MARKER
git add ChangeLog.txt init/init.php public/setup/db_data.php public/setup/maj.php
git status
# Check if public/setup/atomicupdate/ is empty
if [ "$(ls 'public/setup/atomicupdate/')" ]; then
echo -e "\e[0;33mWarning: public/setup/atomicupdate is not empty. Did you forgot to remove some files?\e[0m\n"
fi
echo -e "\e[0;33mApprove changes ? [yes/no]\e[0m\n"
read proceed
proceed=$(echo $proceed | tr '[:upper:]' '[:lower:]');
# Cancel
if [[ $proceed != 'yes' && $proceed != 'y' ]]; then
git reset --hard
echo "Changes cancelled. Bye."
exit;
fi
# Commit
git commit -m "Release v$to"
echo -e "\e[0;33mCommit \"Release v$to\" done\e[0m\n"
# Create tag
tag=0
if [[ $digit2 == '04' || $digit2 == '10' ]]; then
git tag -f "v$to"
echo -e "\e[0;33mTag \"v$to\" done\e[0m\n"
tag=1
fi
if [[ $tag == 1 ]]; then
echo -e "\e[0;33mDo you want to push the release commit and the tag to origin ? [yes/no]\e[0m\n"
else
echo -e "\e[0;33mDo you want to push the release commit to origin ? [yes/no]\e[0m\n"
fi
# Push commit and tag
read proceed
proceed=$(echo $proceed | tr '[:upper:]' '[:lower:]');
if [[ $proceed == 'yes' || $proceed == 'y' ]]; then
git push origin
if [[ $tag == 1 ]]; then
git push origin "v$to"
fi
fi
echo -e "\e[0;33mDone\e[0m\n"