#!/bin/bash
echo -e "BUILD\t: BEGIN `date`"
DIR=`dirname $0`

npm install --save scv-bilara@latest
git status | grep 'nothing to commit' > /dev/null; RC=$?
if [ "$RC" == "0" ]; then
  echo -e "BUILD\t:nothing to commit"
else
  SCV_VER=`json version < node_modules/scv-bilara/package.json`
  MSG="build with scv-bilara v$SCV_VER"
  echo -e "BUILD\t: $MSG"
  git commit -am "$MSG"
  npm version patch
  VERSION=`json version < package.json`
  git reset --soft HEAD~1
  git commit --amend -m "v$VERSION build"
  git push
fi

echo -e "BUILD\t: END `date`"
