This repository has been archived by the owner on Jan 24, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
make-release-build
executable file
·78 lines (67 loc) · 2.05 KB
/
make-release-build
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
#!/bin/bash
# bash is required because we need bash's printf to guarantee a cross-platform
# timestamp format.
set -e
set -x
# make sure we're on a signed tag that matches the version name
versionName=`sed -n 's,.*versionName="\([^"]*\)".*,\1,p' AndroidManifest.xml`
describe=`git describe`
if [ $versionName != $describe ]; then
echo "WARNING: building $describe, which is not the latest release ($versionName)"
else
# make a clearer warning above by putting this here
set +x
echo ""
echo ""
echo "Checking git tag signature for release build:"
git tag -v $versionName
echo ""
echo ""
set -x
fi
if [ -z $ANDROID_HOME ]; then
if [ -e ~/.android/bashrc ]; then
. ~/.android/bashrc
else
echo "ANDROID_HOME must be set!"
exit
fi
fi
projectroot=`pwd`
projectname=`sed -n 's,.*name="app_name">\(.*\)<.*,\1,p' res/values/strings.xml | sed 's,\W,,g'`
# standardize timezone to reduce build differences
export TZ=UTC
# run the clock at 5% speed, ant requires a moving clock
TIMESTAMP=`printf '@%(%Y-%m-%d %H:%M:%S)T x0.05' \
$(git log -n1 --format=format:%at)`
git reset --hard
git clean -fdx
git submodule foreach --recursive git reset --hard
git submodule foreach --recursive git clean -fdx
git submodule sync --recursive
git submodule foreach --recursive git submodule sync
git submodule update --init --recursive
make -C external/ assets
if [ -e ~/.android/ant.properties ]; then
cp ~/.android/ant.properties $projectroot/
else
echo "skipping release ant.properties"
fi
./setup-ant
faketime -f "$TIMESTAMP" ant release
apk=$projectroot/bin/$projectname-$versionName.apk
# mark APK with actual build info, instead of version in manifest
if [ $versionName != $describe ]; then
debugapk=$projectroot/bin/$projectname-$describe.apk
mv $apk $debugapk
apk=$debugapk
fi
if which gpg > /dev/null; then
if [ -z "`gpg --list-secret-keys`" ]; then
echo "No GPG secret keys found, not signing APK"
else
gpg --detach-sign $apk
fi
else
echo "gpg not found, not signing APK"
fi