-
Notifications
You must be signed in to change notification settings - Fork 3
/
generateBuildNumber
executable file
·36 lines (32 loc) · 1.45 KB
/
generateBuildNumber
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
#!/bin/sh
# ============================================================================
# Build No. Generator
# @author: Araf Karsh Hamid
# ============================================================================
PROPS_PATH=src/main/resources
PROPS_BUILD=app.props.build
PROPS_TMPL=app.props.tmpl
PROPS_BACK=$PROPS_PATH/backup
PROPS_FILE=application.properties
CURR_BN=`git rev-list HEAD --count`
if [ -z "$CURR_BN" ]
then
CURR_BN=1
fi
PREV_BN=`expr $CURR_BN - 1`
echo "======================================================================="
echo "Previous Build Number="$PREV_BN
echo "Current Build Number="$CURR_BN
echo "======================================================================="
echo "Taking Properties Backup"
cp $PROPS_PATH/$PROPS_FILE $PROPS_BACK/$PROPS_FILE.$PREV_BN
echo "======================================================================="
echo "Generate Build Numbers"
echo "# =======================================================================" > $PROPS_PATH/$PROPS_BUILD
echo "# $1 Service Properties" >> $PROPS_PATH/$PROPS_BUILD
echo "# =======================================================================" >> $PROPS_PATH/$PROPS_BUILD
echo "build.number="$CURR_BN >> $PROPS_PATH/$PROPS_BUILD
echo "build.date="`date` >> $PROPS_PATH/$PROPS_BUILD
cat $PROPS_PATH/$PROPS_BUILD > $PROPS_PATH/$PROPS_FILE
cat $PROPS_PATH/$PROPS_TMPL >> $PROPS_PATH/$PROPS_FILE
echo "======================================================================="