docker-android/release.sh

114 lines
2.3 KiB
Bash
Raw Normal View History

#!/bin/bash
# Bash version should >= 4 to be able to run this script.
IMAGE="butomo1989/docker-android"
2017-03-28 11:31:14 +01:00
LATEST_BUILD_TOOL=25.0.2
if [ -z "$1" ]; then
read -p "Environment (test|build|push|all) : " TASK
else
TASK=$1
fi
if [ -z "$2" ]; then
read -p "Android version: " GIVEN_VERSION
else
GIVEN_VERSION=$2
fi
if [ -z "$3" ]; then
read -p "Processor type (x86|arm): " PROCESSOR
else
PROCESSOR=$3
fi
2017-03-28 11:31:14 +01:00
function api_level() {
declare -A levels=(
[5.0.1]=21
[5.1.1]=22
[6.0]=23
[7.0]=24
[7.1.1]=25
)
2017-03-28 11:31:14 +01:00
for key in "${!levels[@]}"; do
if [[ $key == *"$GIVEN_VERSION"* ]]; then
version=$key
fi
done
# If version cannot be found in the list
if [ -z "$version" ]; then
echo "Version is not found in the list or not supported! Support only version 5.0.1, 5.1.1, 6.0, 7.0, 7.1.1"
exit 1
fi
echo "Android version: $version"
level=${levels[$version]}
echo "Api level: $level"
}
function system_image() {
case $PROCESSOR in
x86)
sys_img=x86_64
;;
arm)
sys_img=armeabi-v7a
;;
*)
echo "Invalid processor! Valid options: x86, arm"
exit 1
;;
esac
echo "Processor: $PROCESSOR"
echo "System Image: $sys_img"
}
function init() {
api_level
system_image
}
init
2017-03-28 11:31:14 +01:00
echo "Build tool: $build_tool"
IMAGE_NAME="$IMAGE-$PROCESSOR-$version"
echo "Image tag: $TAG"
function test() {
(export ANDROID_HOME=/root && export ANDROID_VERSION=$version && export API_LEVEL=$level \
&& export PROCESSOR=$PROCESSOR && export SYS_IMG=$sys_img && nosetests -v)
}
function build() {
# Remove pyc files
find . -name "*.pyc" -exec rm -f {} \;
2017-03-28 11:31:14 +01:00
docker build -t $IMAGE_NAME --build-arg ANDROID_VERSION=$version --build-arg BUILD_TOOL=$LATEST_BUILD_TOOL \
--build-arg API_LEVEL=$level --build-arg PROCESSOR=$PROCESSOR --build-arg SYS_IMG=$sys_img .
}
function push() {
docker push $IMAGE_NAME
}
case $TASK in
test)
test
;;
build)
build
;;
push)
push
;;
all)
test
build
push
;;
*)
echo "Invalid environment! Valid options: test, build, push, all"
;;
esac