-
Notifications
You must be signed in to change notification settings - Fork 4
/
versioning.sh
executable file
·37 lines (26 loc) · 1 KB
/
versioning.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
#/bin/bash
#echo "Auto Version: `pwd`"
CODE=`git tag | grep -c ^v[0-9]`
NAME=`git describe --dirty | sed -e 's/^v//'`
COMMITS=`echo ${NAME} | sed -e 's/[0-9\.]*//'`
DATE=`date +"%d-%m-%Y"`
if [ "x${COMMITS}x" = "xx" ] ; then
VERSION="${NAME}"
else
BRANCH=" (`git branch | grep "^\*" | sed -e 's/^..//'`)"
VERSION="${NAME}${BRANCH}"
VERSION=`echo "${VERSION}" | tr '\/' '-'`
fi
#echo " Code: ${CODE}"
#echo " Ver: ${VERSION}"
cat ./AndroidManifest.xml | \
sed -e "s/android:versionCode=\"[0-9][0-9]*\"/android:versionCode=\"${CODE}\"/" \
-e "s/android:versionName=\".*\"/android:versionName=\"${VERSION}\"/" \
> ./bin/AndroidManifest.xml
cat ./src/pt/lsts/accu/AboutPanel.java | \
sed -e "s/String versionString = \".*\";/String versionString = \"${VERSION}\";/" \
-e "s/String dateString = \".*\";/String dateString = \"${DATE}\";/" \
> ./bin/AboutPanel.java
cp bin/AndroidManifest.xml AndroidManifest.xml
cp ./bin/AboutPanel.java ./src/pt/lsts/accu/AboutPanel.java
exit 0