#!/bin/sh

#  build-dev.sh
#  AutomaticBuild
#

BUILD_NAME=$1

if [ ! $BUILD_NAME ]; then
  echo "Icorrect usage"
  echo "Use this command in next format: "
  echo "  build <built-type> "
  echo " "
  echo " Exampes :"
  echo "   build dev"
  echo "   build client"
  exit 1
fi


start=$SECONDS

chmod +x scripts/*.sh
chmod +x scripts/*.py

./scripts/archive.sh ${BUILD_NAME} $2
if [ "$?" -ne "0" ]; then
  exit 1
fi

./scripts/create-ipa.sh ${BUILD_NAME} $2
if [ "$?" -ne "0" ]; then
  exit 1
fi


./scripts/upload-to-ftp.sh ${BUILD_NAME} $2
if [ "$?" -ne "0" ]; then
  exit 1
fi

end=$SECONDS
echo "Total build time: $((end - start)) secs."