set -e

echo "duer-jsbridge build run: "
npm run build:pro

echo "duer-jsbridge existing version: "

npm view duer-jsbridge versions

VERSION=`npx select-version-cli`

read -p "Releasing $VERSION - are you sure? (y/n)" -n 1 -r


if [[ $REPLY =~ ^[Yy]$ ]]
then
  echo "Releasing $VERSION ..."
  npm run changelog -- --release-as $VERSION
  # build
    VERSION=$VERSION
  if [[ $VERSION =~ "-" ]]
  then
    npm publish --tag beta --registry https://registry.npmjs.org
  else
    npm publish --registry https://registry.npmjs.org
  fi
fi


