-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·85 lines (72 loc) · 1.61 KB
/
publish.sh
File metadata and controls
executable file
·85 lines (72 loc) · 1.61 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
extract_version()
{
LIB_VER=$(cat package.json | grep "version\": " | cut -d\" -f4 | cut -d- -f1)
LIB_VER_MAJOR=$(echo $LIB_VER | cut -d. -f1)
LIB_VER_MINOR=$(echo $LIB_VER | cut -d. -f2)
LIB_VER_INCRM=$(echo $LIB_VER | cut -d. -f3)
LIB_VER_CURRENT=$LIB_VER_MAJOR.$LIB_VER_MINOR.$LIB_VER_INCRM
}
add_incremental_ver()
{
LIB_VER_NEXT=$LIB_VER_MAJOR.$LIB_VER_MINOR.$(($LIB_VER_INCRM + 1))
}
add_minor_ver()
{
LIB_VER_NEXT=$LIB_VER_MAJOR.$(( $LIB_VER_MINOR + 1)).0
}
set_version()
{
cat package.json | sed -e "s/version\":\s*\".*\"/version\": \"$1\"/g" > package.json.new
rm package.json
mv package.json.new package.json
git add package.json
}
ask_proceed()
{
read -p "Proceed $1 [Y/n/p]? " YN
if [ "${YN,,}" = "n" ]; then
exit 0
fi
}
extract_version
echo $LIB_VER_CURRENT
ask_proceed "Set Version"
if [ "${YN,,}" != "p" ]; then
read -p "Incrementally increase version [Y/n]? " YN
if [ "${YN,,}" == "y" ]; then
add_incremental_ver
else
add_minor_ver
fi
set_version $LIB_VER_NEXT
fi
ask_proceed "Documentation"
if [ "${YN,,}" != "p" ]; then
npm run jsdoc
fi
ask_proceed "Compile to CommonJS"
if [ "${YN,,}" != "p" ]; then
npm run compile
fi
ask_proceed "Test"
if [ "${YN,,}" != "p" ]; then
npm run test
fi
ask_proceed "Commit"
if [ "${YN,,}" != "p" ]; then
git add docs/
git add -u
git add -i
git commit
fi
ask_proceed "Publish"
if [ "${YN,,}" != "p" ]; then
npm publish
git tag v$LIB_VER_NEXT
fi
ask_proceed "Push"
if [ "${YN,,}" != "p" ]; then
git push --all
git push --tags
fi