-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathset_ci_version.sh
More file actions
executable file
·66 lines (55 loc) · 1.51 KB
/
set_ci_version.sh
File metadata and controls
executable file
·66 lines (55 loc) · 1.51 KB
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
#!/bin/bash
BIRTHDAY="Tue Apr 20 12:00:00 EDT 2012";
BIRTHDAY_TIMESTAMP=1334941200;
today="$(echo `date`)"
todayTimestamp="$(echo `date +%s`)"
echo ""
echo "____========== Getting the version code for today =============_______"
echo " Birthday: $BIRTHDAY"
echo " Today: $today"
echo " Birthday: $BIRTHDAY_TIMESTAMP "
echo " Today: $todayTimestamp"
echo ""
echo ""
let WEEK_DIFF=`expr $todayTimestamp - $BIRTHDAY_TIMESTAMP`/60/60/24/7 || exit 4;
if [ "$WEEK_DIFF" -gt 208 ]
then
YEAR_DIFF=4
WEEK_DIFF=`expr $WEEK_DIFF - 208`
elif [ "$WEEK_DIFF" -gt 156 ]
then
YEAR_DIFF=3
WEEK_DIFF=`expr $WEEK_DIFF - 156`
elif [ "$WEEK_DIFF" -gt 104 ]
then
YEAR_DIFF=2
WEEK_DIFF=`expr $WEEK_DIFF - 104`
elif [ "$WEEK_DIFF" -gt 52 ]
then
YEAR_DIFF=1
WEEK_DIFF=`expr $WEEK_DIFF - 52`
else
YEAR_DIFF=0
fi
# NOW=`date +%Y.%m.%d.%H.%M`
MINOR_VERSION=`date +%d.%H.%M`
DAY=`date +%d`
SHORT_VERSION="$YEAR_DIFF.$WEEK_DIFF.$DAY"
version="$YEAR_DIFF.$WEEK_DIFF.$MINOR_VERSION"
echo " Birthday: $BIRTHDAY"
echo " Today: $today"
echo " Years: $YEAR_DIFF"
echo " Weeks: $WEEK_DIFF"
echo " -> Version: $version"
echo ""
echo "... setting version on dative package"
sed 's/"version": "[^,]*"/"version": "'$SHORT_VERSION'"/' package.json > output
mv output package.json
mkdir dist
cp package.json dist/
# echo "... setting Continuous Integration version on dative dist"
# sed "s/\"\(version\": \"[^,]*\)\"/\1.$MINOR_VERSION\"/" dist/package.json > output
# mv output dist/package.json
# echo $MINOR_VERSION
echo "..... Done."
exit 0;