-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.sh
executable file
·65 lines (55 loc) · 1.3 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
BRANCH=`git branch -a|grep '.*\*'|sed 's/[*[:space:]]*//g'` # 当前分支
STATUS=`git status --porcelain` # working tree
if [ "$STATUS" ]; then
echo "❗️请先清理 workingtree 后再进行发布!"
echo ""
exit 1
fi
# build clent
echo "正在打包Client..."
cd report-client
read -r -p "report-client是否需要npm i? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
npm ci
;;
[nN][oO]|[nN])
echo "No"
;;
*)
esac
npm run build
cd ..
# npm ci
# npm run build
sleep 3
if [ -z "$1" ]; then
type='prerelease'
else
type=$1
fi
if [ $BRANCH != "master" ] && [ $type == "patch" ]
then
echo 'error: 请在master上发布patch版本!'
exit 1
fi
echo "正在发包npm..."
npm version $type -m '[release] '$type': @%s' && npm publish --registry=https://registry.npmjs.org/ --access=public
# echo [ $? -eq 0 ]
# then
# PACKAGE_VERSION=$(cat package.json \
# | grep version \
# | head -1 \
# | awk -F: '{ print $2 }' \
# | sed 's/[",]//g')
# git push origin $BRANCH:$BRANCH
# fi
STAT=$?
if [ $STAT == 0 ]
then
echo 'success: 发包成功!请手动提交你的代码'
else
echo 'error: 发包失败!请重新执行:npm publish --registry=https://registry.npmjs.org/ --access=public'
fi
echo '执行完成'