This repository has been archived by the owner on May 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathdeploy
executable file
·58 lines (48 loc) · 1.62 KB
/
deploy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/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