-
Notifications
You must be signed in to change notification settings - Fork 347
/
avc-version
executable file
·109 lines (94 loc) · 2.64 KB
/
avc-version
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
#! /bin/bash
usage()
{
echo "usage: $0 {get | set <version>}"
exit 1
}
set +x
if [[ $# < 1 ]]
then
usage
fi
version_str='__version__ ='
case "$1" in
get)
(
for f in $(find src tools -type f -exec grep -l "$version_str" {} \;)
do
echo -n "$f: "
grep "$version_str" $f
done
echo -n "setup.py: "
grep version setup.py
echo -n "sphinx/conf.py: "
grep release sphinx/conf.py
) | awk "
function version_to_number(v) {
n = split(v, a, \".\");
r = 0;
for (j=n; j>0; j--) {
r += a[j] * 1000**(n-j);
}
return r;
}
BEGIN {
FS = \"[=:]+\"; max=-1
}
{
gsub(/[,' ]+/, \"\", \$NF);
files[NR]=\$1; v=\$NF; versions[NR]=v;
v2n=version_to_number(v);
if (v2n > max)
max=v2n
}
END {
for (i in files) {
if (version_to_number(versions[i]) == max) {
s=\" MAX 👈\"
} else {
s = \"\"
}
printf(\"%-65s: %s%s\\n\", files[i], versions[i], s)
}
}
"
;;
set)
if [[ $# != 2 ]]
then
usage
fi
version="$2"
for f in $(find src tools -type f -exec grep -l "$version_str" {} \;)
do
echo "<<< $f >>>"
case "$(uname)" in
Darwin)
sed -E -i '' -e "s@$version_str \'[0-9abr.]+\'@$version_str \'$version\'@" $f
;;
Linux)
sed -E -i -e "s@$version_str '[0-9abr.]+'@$version_str '$version'@" $f
;;
esac
done
echo "<<< setup.py >>>"
case "$(uname)" in
Darwin)
sed -E -i '' -e "s@version='[0-9abr.]+'@version='$version'@" setup.py
;;
Linux)
sed -E -i -e "s@version='[0-9abr.]+'@version='$version'@" setup.py
;;
esac
echo '<<< sphinx/conf.py >>>'
case "$(uname)" in
Darwin)
# release = '22.3.0'
sed -E -i '' -e "s@release = '[0-9abr.]+'@release = '$version'@" sphinx/conf.py
;;
Linux)
sed -E -i -e "s@release = '[0-9abr.]+'@release = '$version'@" sphinx/conf.py
;;
esac
;;
esac