-
Notifications
You must be signed in to change notification settings - Fork 10
/
deploy.sh
executable file
·111 lines (93 loc) · 2.3 KB
/
deploy.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
######################################################
# CanAirIO deploy release utility
#
# Author: @hpsaturn
# 2021
######################################################
SRC_REV=`cat gradle.properties | grep mVersionCode | sed -n -e 's/^.*mVersionCode=//p'`
SRC_VER=`cat gradle.properties | grep mVersionName | sed -n -e 's/^.*mVersionName=//p'`
DATE=`date +%Y%m%d`
RELDIR="releases"
RELNAME="rev${SRC_REV}v${SRC_VER}_signed${DATE}.apk"
OUTPUT="${RELDIR}/${RELNAME}"
showHelp () {
echo ""
echo "************************************************"
echo "** Build and deploy tag and release **"
echo "************************************************"
echo ""
echo "Usage alternatives:"
echo ""
echo "./deploy clean"
echo "./deploy build"
echo "./deploy publish"
echo ""
}
clean () {
./gradlew clean
}
build () {
echo ""
echo "***********************************************"
echo "** Building $RELNAME"
echo "***********************************************"
echo ""
./gradlew clean
./gradlew build
./gradlew assembleRelease
cp app/build/outputs/apk/release/app-release.apk $OUTPUT
echo ""
echo ""
echo "***********************************************"
echo "************** Build done *********************"
echo "***********************************************"
echo ""
md5sum $OUTPUT
echo ""
}
publish_release () {
echo ""
echo "***********************************************"
echo "********** Publishing release *****************"
echo "***********************************************"
echo ""
git tag -a "v${SRC_VER}" -m "release v${SRC_VER} rev${SRC_REV}"
git push origin "v${SRC_VER}"
git log -n 10 --pretty=format:"%h %s" | gh release create "v${SRC_VER}" -F - -t "v${SRC_VER}" -p ${OUTPUT}
}
current_branch=`git rev-parse --abbrev-ref HEAD`
if [ ${current_branch} != "release" ]; then
echo ""
echo "Error: you are in ${current_branch} branch please change to release branch."
echo ""
exit 1
fi
if [ "$1" = "" ]; then
showHelp
else
case "$1" in
clean)
clean
;;
help)
showHelp
;;
--help)
showHelp
;;
-help)
showHelp
;;
print)
printOutput
;;
publish)
publish_release
;;
*)
build $1
;;
esac
fi
exit 0