-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrel.sh
executable file
·50 lines (40 loc) · 1.41 KB
/
rel.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
INDEX_FILE="index.html"
INIT_FILE="engine/Init.js"
VERSION_FILE="VERSION"
REL_DATE=$(date +%Y-%m-%d)
REV_INNER=$(($(git rev-list `git rev-list --tags --no-walk --max-count=1`..HEAD --count engine)))
REV_TOTAL_OLD=$(sed -n "s:.*REVISION_TOTAL = \(.*\);:\1:p" $INIT_FILE)
REV_TOTAL=$(($REV_TOTAL_OLD+$REV_INNER))
if [ "$1" ]; then
VERSION_NEW=$1;
else
VERSION_OLD=$(sed -n "s:.*ENGINE_VERSION = \"\(.*\)\";:\1:p" $INIT_FILE)
IFS=\. read -a numbers <<<"$VERSION_OLD"
VM=$((10#${numbers[2]} + 1))
echo $VM;
if [ "$VM" -lt 10 ]; then
VM=0$VM;
fi
VERSION_NEW=${numbers[0]}.${numbers[1]}.$VM;
fi
echo updating $VERSION_OLD to $VERSION_NEW
sed -i.bak "s/\(\?v=\).*\(\"\)/\1$VERSION_NEW\2/g" $INDEX_FILE
sed -i.bak "s/\(ENGINE_VERSION = \"\).*\(\";\)/\1$VERSION_NEW\2/g" $INIT_FILE
sed -i.bak "s/\(RELEASE_DATE = \"\).*\(\";\)/\1$REL_DATE\2/g" $INIT_FILE
sed -i.bak "s/\(REVISION_INNER = \).*\(;\)/\1$REV_INNER\2/g" $INIT_FILE
sed -i.bak "s/\(REVISION_TOTAL = \).*\(;\)/\1$REV_TOTAL\2/g" $INIT_FILE
rm $INDEX_FILE.bak
rm $INIT_FILE.bak
echo $VERSION_NEW > $VERSION_FILE
VERSION_TAG=${VERSION_NEW,,}
VERSION_TAG=${VERSION_TAG/ /.}
MESSAGE="v$VERSION_TAG
This is an automated commit."
git stage $INIT_FILE
git stage $INDEX_FILE
git stage $VERSION_FILE
git commit -m "$MESSAGE"
git tag -a "$VERSION_TAG" -m "$MESSAGE"
git push 5apps master
git push origin master --tags
git push public master --tags