-
Notifications
You must be signed in to change notification settings - Fork 41
/
bump_version.sh
executable file
·74 lines (72 loc) · 1.97 KB
/
bump_version.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
#!/bin/bash
current_version=$(git describe --tags --abbrev=0)
function error
{
echo
echo "ERROR *** $1"
}
if [ "$1" == "-d" ]; then
do=0
shift
else
do=1
fi
if [ "$1" == "" ]; then
echo
echo "Syntax: $0 [-d] {new_version} [commit message]"
echo
echo " -d : dry run, generate json and update properties but do not run git commands"
echo ""
echo " Current version: $current_version"
echo
else
tm=$(git status --porcelain -- src/TinyMqtt.h | wc -l)
echo "Current version: ($current_version)"
echo "New version : ($1)"
echo "Take info from : library.properties"
if [ "$tm" == "1" ]; then
error "You cannot bump version if TinyMqtt.h is modified"
exit
fi
echo -n "Do you want to proceed ? "
read a
if [ "$a" == "y" ]; then
echo "Doing this..."
grep $current_version library.properties
if [ "$?" == "0" ]; then
sed -i "s/$current_version/$1/" library.properties
sed -i "s/#define TINY_MQTT_REVISION/#define TINY_MQTT_REVISION \"$1\"/" src/TinyMqtt.h
cp library.json.skeleton library.json
while ifs= read -r line; do
name=$(echo "$line" | sed "s/=.*//g")
value=$(echo "$line" | cut -d= -f 2 | sed 's/"//g')
echo " Replacing $name in json"
if [ "$name" == "depends" ]; then
depends=$(echo "$value" | sed "s/,/ /g")
echo " Depends=$depends"
fi
sed -i "s@#$name@$value@g" library.json
done < library.properties
deps=""
for depend in $depends; do
if [ "$deps" != "" ]; then
deps="$deps, "
fi
deps="$deps'$depend' : '*'"
done
sed -i "s@#dependencies@$deps@g" library.json
sed -i "s/'/\"/g" library.json
if [ "$do" == "1" ]; then
echo "Pushing all"
git add library.properties
git add library.json
git commit -m "Release $1 $2"
git tag $1
git push
git push --tags
fi
else
error "Current version does not match library.property version, aborting"
fi
fi
fi