UNPKG

1.23 kBapplication/x-shView Raw
1# 1. 获取令牌
2# cat|$1
3
4if [ $# == 0 ];then
5 NPM_TOKEN=`cat NPM_TOKEN`
6else
7 NPM_TOKEN=$1
8fi
9
10
11# 2. 登录 npm 服务器
12# - npm adduser --registry=https://registry.npmjs.org/
13
14npm adduser --registry=https://registry.npmjs.org/ <<!
15blibee
16$NPM_TOKEN
17ye.rong@bianlifeng.com
18!
19
20
21# 3. 获取 npm 上 latest 版本号
22# - npm info bee-ui|grep|awk
23
24latestVersion=`npm info bee-ui|grep 'version:'`
25latestVersion=`echo $latestVersion|awk '{print substr($0,11,length-12)}'`
26echo latest: $latestVersion
27
28
29# 4. 本地 package.json 版本号
30# - cat package.json|grep|awk
31
32version=`cat package.json|grep 'version'`
33version=`echo $version|awk '{print substr($0,13,length-14)}'`
34echo version: $version
35
36
37# 5. 有更新则发布 latest
38# - npm publish
39
40if [ $version != $latestVersion ];then
41 echo `npm publish`
42fi
43
44
45# 6. 更新时间戳发布 nightly
46# - sed && npm publish --tag=nightly
47
48timestamp=`date +%Y%m%d%H%M%S`
49nightlyVersion=`echo $version-$timestamp`
50echo nightly: $nightlyVersion
51
52sed -i '' 's/"version": "'$version'"/"version": "'$nightlyVersion'"/g' package.json
53echo `npm publish --tag=nightly`
54
55
56# 7. 复原 package.json
57sed -i '' 's/"version": "'$nightlyVersion'"/"version": "'$version'"/g' package.json
58echo done