#!/usr/bin/env bash set -e BIN="./node_modules/.bin" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" VERSION=$(node -e "console.log(require('$DIR/../package.json').version)") PACKAGE=$(node -e "console.log(require('$DIR/../package.json').name)") TAG_NAME="v$VERSION" TAG_EXISTS=$(git tag -l "$TAG_NAME") if [ ! -z "$TAG_EXISTS" ]; then echo "There is already a tag $TAG_EXISTS in git. Skiping git deploy." else echo "Deploying $VERSION to git" LAST_COMMIT=$(git log -1 --pretty=%B) git checkout -b dist grep -v '^build$' .gitignore > /tmp/.gitignore mv /tmp/.gitignore .gitignore git add --force build/* git commit -am "$TAG_NAME" git tag "$TAG_NAME" -m "$LAST_COMMIT" git checkout master git push origin $TAG_NAME git branch -D dist fi NPM_EXISTS=$(npm info $PACKAGE@$VERSION) if [ ! -z "$NPM_EXISTS" ]; then echo "There is already a version $VERSION in npm. Skiping npm publish." else echo "Deploying $VERSION to npm" npm publish fi CDN_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" https://cdn.auth0.com/js/lock-passwordless-$VERSION.min.js | grep 200 || true) if [ ! -z "$CDN_EXISTS" ]; then echo "There is already a version $VERSION in the CDN. Skiping cdn publish." else echo "Deploying $VERSION to cdn" $BIN/grunt cdn fi echo "Preparing gh-pages deployment" $BIN/grunt ghpages echo "Publishing latest to gh-pages" git subtree split --prefix support/playground -b gh-pages git checkout gh-pages rm -rf node_modules support npm-debug.log git add . git commit -m "Automated gh-page Publish" git push -f origin gh-pages git checkout master git branch -D gh-pages