-
Notifications
You must be signed in to change notification settings - Fork 16
/
release.sh
executable file
·48 lines (36 loc) · 1.21 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
48
#!/bin/sh
# @NOTE Use `bower register yod-mock git@github.com:qiu8310/yod-mock.git` to register bower module.
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
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