forked from halibobo1205/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ver.sh
executable file
·31 lines (26 loc) · 926 Bytes
/
ver.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
#!/bin/bash
set -x
currentBranch=`git rev-parse --abbrev-ref HEAD`
if [ "$currentBranch"x != "master"x ]
then
echo The current branch is not master. Please checkout into master.
exit 1
else
git pull origin master
fi
versionName=`git describe --tags`
versionCode=`git rev-list HEAD --count`
versionBranch=version/$versionName
git checkout -b $versionBranch
if [ $? -ne 0 ]
then
echo A branch named $versionBranch already exists. Will delete the local and remote branch and re run.
git branch -D $versionBranch
git push origin :$versionBranch
git checkout -b $versionBranch
fi
versionPath="src/main/java/org/tron/program/Version.java"
sed -i -e "s/VERSION_NAME.*$/VERSION_NAME = \"$versionName\";/g;s/VERSION_CODE.*$/VERSION_CODE = \"$versionCode\";/g" $versionPath
git add $versionPath
git commit -m "update a new version. version name:$versionName,version code:$versionCode"
git push origin $versionBranch