2015-06-04 19:24:05 +00:00
|
|
|
#!/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:"
|
2016-01-14 19:57:57 +00:00
|
|
|
gpg --list-key 9F0FE587374BBE81 || gpg --recv-key 9F0FE587374BBE81
|
|
|
|
gpg --list-key E9E28DEA00AA5556 || gpg --recv-key E9E28DEA00AA5556
|
|
|
|
gpg --list-key A801183E69B37AA9 || gpg --recv-key A801183E69B37AA9
|
2015-06-04 19:24:05 +00:00
|
|
|
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
|
|
|
|
|
2016-01-14 20:08:46 +00:00
|
|
|
if [ -z $ANDROID_NDK_HOME ]; then
|
|
|
|
if which ndk-build 2>&1 /dev/null; then
|
|
|
|
ANDROID_NDK_HOME=`which ndk-build | sed 's,/ndk-build,,'`
|
|
|
|
else
|
|
|
|
echo "ANDROID_NDK_HOME not set and 'ndk-build' not in PATH"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-06-04 19:24:05 +00:00
|
|
|
projectroot=`pwd`
|
|
|
|
projectname=`sed -n 's,.*name="app_name">\(.*\)<.*,\1,p' res/values/strings.xml`
|
|
|
|
|
|
|
|
# standardize timezone to reduce build differences
|
|
|
|
export TZ=UTC
|
|
|
|
TIMESTAMP=`printf '%(%Y-%m-%d %H:%M:%S)T' \
|
|
|
|
$(git log -n1 --format=format:%at)`
|
|
|
|
|
|
|
|
git reset --hard
|
|
|
|
git clean -fdx
|
|
|
|
git submodule foreach git reset --hard
|
|
|
|
git submodule foreach git clean -fdx
|
|
|
|
git submodule sync
|
|
|
|
git submodule foreach git submodule sync
|
|
|
|
git submodule update --init --recursive
|
|
|
|
|
|
|
|
|
|
|
|
if [ -e ~/.android/ant.properties ]; then
|
|
|
|
cp ~/.android/ant.properties $projectroot/
|
|
|
|
else
|
|
|
|
echo "skipping release ant.properties"
|
|
|
|
fi
|
|
|
|
|
2016-01-14 20:09:45 +00:00
|
|
|
faketime "$TIMESTAMP" $ANDROID_NDK_HOME/ndk-build
|
2016-01-06 21:14:08 +00:00
|
|
|
|
2016-01-26 23:29:37 +00:00
|
|
|
#clean, build, clean and build!
|
2016-01-27 08:18:39 +00:00
|
|
|
make -C external clean
|
2016-01-27 08:41:53 +00:00
|
|
|
APP_ABI=armeabi faketime "$TIMESTAMP" make -C external
|
2016-10-25 01:54:54 +00:00
|
|
|
#make -C external clean
|
|
|
|
#APP_ABI=x86 faketime "$TIMESTAMP" make -C external
|
2016-01-06 21:14:08 +00:00
|
|
|
|
2016-10-25 01:54:54 +00:00
|
|
|
assembleRelease
|
|
|
|
#./setup-ant
|
|
|
|
#ant release
|
2015-06-04 19:24:05 +00:00
|
|
|
|
2016-10-25 01:54:54 +00:00
|
|
|
#apk=$projectroot/bin/$projectname-v$describe.apk
|
|
|
|
apk=$projectroot/app/build/outputs/apk/app-release-unsigned.apk
|
2015-06-04 19:24:05 +00:00
|
|
|
|
2016-01-14 19:59:17 +00:00
|
|
|
# standardize timestamps in ZIP headers, requires strip-nondeterminism 0.014
|
|
|
|
if which strip-nondeterminism > /dev/null; then
|
|
|
|
strip-nondeterminism -t zip -T $(git log -n1 --format=format:%at) $apk
|
|
|
|
fi
|
|
|
|
|
|
|
|
# echo the checksum to build logs
|
|
|
|
sha256sum $apk
|
|
|
|
|
2015-06-04 19:24:05 +00:00
|
|
|
if which gpg > /dev/null; then
|
|
|
|
if [ -z "`gpg --list-secret-keys`" ]; then
|
|
|
|
echo "No GPG secret keys found, not signing APK"
|
|
|
|
else
|
|
|
|
gpg --armor --detach-sign $apk
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "gpg not found, not signing APK"
|
|
|
|
fi
|