diff --git a/.travis.yml b/.travis.yml index 540b19f..159100e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,12 @@ services: install: "pip install -r requirements.txt" env: - matrix: - - ANDROID_VERSION=5.0.1 - - ANDROID_VERSION=5.1.1 - - ANDROID_VERSION=6.0 - - ANDROID_VERSION=7.0 - - ANDROID_VERSION=7.1.1 + - ANDROID_VERSION=5.0.1 + - ANDROID_VERSION=5.1.1 + - ANDROID_VERSION=6.0 + - ANDROID_VERSION=7.0 + - ANDROID_VERSION=7.1.1 + - REAL_DEVICE=True script: bash travis.sh diff --git a/release_real.sh b/release_real.sh new file mode 100644 index 0000000..6d94bf4 --- /dev/null +++ b/release_real.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +if [ -z "$1" ]; then + read -p "Task (build|push|all) : " TASK +else + TASK=$1 +fi + +if [ -z "$2" ]; then + read -p "Release version: " RELEASE +else + RELEASE=$2 +fi + +IMAGE="butomo1989/docker-android" +FILE_NAME=docker/Real_device + +image_version="$IMAGE-real-device:$RELEASE" +image_latest="$IMAGE-real-device:latest" + +function build() { + echo "[BUILD] Image name: $image_version and $image_latest" + echo "[BUILD] Dockerfile: $FILE_NAME" + docker build -t $image_version -f $FILE_NAME . + docker tag $image_version $image_latest +} + +function push() { + echo "[PUSH] Image name: $image_version and $image_latest" + docker push $image_version + docker push $image_latest +} + +case $TASK in + build) + build + ;; + push) + push + ;; + all) + build + push + ;; + *) + echo "Invalid environment! Valid options: test, build, push, all" + ;; +esac diff --git a/travis.sh b/travis.sh index 313ca32..8fb5c7c 100755 --- a/travis.sh +++ b/travis.sh @@ -5,10 +5,15 @@ if [ -z "$TRAVIS_TAG" ]; then echo "UNIT TEST ONLY" bash release.sh test all all 0.1 else - echo "Log in to docker hub" - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" - echo "[Version: $ANDROID_VERSION] RUN UNIT TEST, BUILD DOCKER IMAGES AND PUSH THOSE TO DOCKER HUB" - bash release.sh all $ANDROID_VERSION all $TRAVIS_TAG + if [ ! -z "$ANDROID_VERSION" ]; then + echo "Log in to docker hub" + docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" + echo "[Version: $ANDROID_VERSION] RUN UNIT TEST, BUILD DOCKER IMAGES AND PUSH THOSE TO DOCKER HUB" + bash release.sh all $ANDROID_VERSION all $TRAVIS_TAG + elif [ ! -z "$REAL_DEVICE" ]; then + echo "[SUPPORT FOR REAL DEVICE: BUILD DOCKER IMAGES AND PUSH THOSE TO DOCKER HUB ]" + bash release_real.sh all $TRAVIS_TAG + fi echo "Log out of docker hub" docker logout fi