#! /bin/bash
set -e

VERSION=`git describe --tags`

if [ ! -d ../WebApp-Releases ]; then
  echo "Making new Releases Directory"
  mkdir ../WebApp-Releases
fi

echo "Building releases for $VERSION"

echo "Building Prod Release..."

npm run build:prod

tar -czf ../WebApp-Releases/LocalLoop-Web-prod-$VERSION.tar.gz dist

echo "Building Dev Release..."

npm run build:dev

tar -czf ../WebApp-Releases/LocalLoop-Web-dev-$VERSION.tar.gz dist

echo "Cleaning up build artefacts..."

rm -rf dist

echo "Done"