-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathpublish.sh
66 lines (49 loc) · 1.75 KB
/
publish.sh
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
59
60
61
62
63
64
65
66
#!/bin/bash -e
echo ""
echo "|************************|"
echo "| NPM Publishing |"
echo "|************************|"
echo ""
echo "This script will publish a new version to NPM, create a version bump git commit, tag it and push it."
read -p "Press [Enter] to continue";
branchName=`git rev-parse --abbrev-ref HEAD`
if [[ $branchName != "master" ]]; then
echo "Current branch is $branchName. Only the master branch can be published."
exit 1
fi
containsChanges=`git status --short --untracked-files=no`
if [[ $containsChanges ]]; then
echo "Branch contains uncommitted changes."
echo "$containsChanges"
exit 1
fi
containsDiffs=`git fetch && git diff master..origin/master --shortstat`
if [[ $containsDiffs ]]; then
echo "Local/Origin branches are not in sync."
echo $containsDiffs
exit 1
fi
echo "What type of publish?"
select version_type in "patch" "minor" "major"; do
read -p "Creating commit and tag for a $version_type release. Press [Enter] to continue";
break
done
npm run lint
npm run compile
npm run test
open ./test/browser/index.html
read -p "Are browser tests OK? Press [Enter] to continue";
# Use npm to increment the version and capture it
version_with_v=`npm version $version_type -m "Version Bump to %s ($version_type)"`
# Remove the "v" from v1.2.3 to get 1.2.3 to tag without the "v"
version=`echo $version_with_v | cut -b 2-`
git tag -d $version_with_v &>/dev/null
git tag $version
packageName=`npm pkg get name | xargs echo`
registry=`npm config get registry`
gitOriginUrl=`git remote get-url origin`
read -p "Ready to publish $packageName@$version to $registry. Press [Enter] to continue"
npm publish --ignore-scripts
read -p "Ready to push master to $gitOriginUrl. Press [Enter]"
git push origin master
git push origin $version