-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrelease.sh
executable file
·47 lines (38 loc) · 1.31 KB
/
release.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
#!/bin/sh
function exit_if_last_not_success() {
if [[ "$?" != '0' ]] ; then
[[ -n $1 ]] && echo $1
exit $?
fi
}
function get_package_version() {
echo $(cat package.json | grep -F '"version"' | awk '{print $2}' | sed 's/"//g' | sed 's/,//g')
}
which git-release > /dev/null
exit_if_last_not_success '\033[31m git-release required, install it in\033[0m \033[34mhttps://github.com/tj/git-extras\033[0m'
if test $# -gt 0; then
npm test
exit_if_last_not_success
git pull
exit_if_last_not_success
cur_version=$(get_package_version)
version=$1
echo Current package version $cur_version, bump to $version
sed -i "" "s/\"version\": *\"${cur_version}\"/\"version\": \"${version}\"/g" package.json
sed -i "" "s/\"version\": *\"${cur_version}\"/\"version\": \"${version}\"/g" bower.json
update_version=$(get_package_version)
if [[ $update_version != $version ]] ; then
echo '\033[31m version update failed \033[0m'
exit 1
fi
./node_modules/.bin/webpack src/yod.js --output-file="browser/yod.js"
./node_modules/.bin/webpack src/yod.js --output-file="browser/yod.min.js" --optimize-minimize
cp browser/yod.* gh-pages
git-changelog -t $1 \
&& git-release $1 \
&& echo 'npm publish ... ' \
&& npm publish -d
else
echo '\033[31m version number required \033[0m'
exit 1
fi