forked from clappr/clappr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bump
executable file
·84 lines (72 loc) · 1.84 KB
/
bump
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
#!/bin/bash
update_dependencies() {
echo 'updating dependencies' &&
npm update --silent
}
update_version() {
current_tag=$(git describe --abbrev=0 --tags) &&
echo 'bump from '$current_tag' to '$1 &&
sed -i ".bkp" "s/\(version\":[ ]*\"\)$current_tag/\1$1/" package.json &&
sed -i ".bkp" "s/\(version\":[ ]*\"\)$current_tag/\1$1/" yuidoc.json
}
update_bower() {
./node_modules/sync-pkg/bin/sync.js
}
build() {
echo 'building clappr.js' &&
npm run build --silent &&
echo 'building clappr.min.js' &&
npm run release --silent
}
run_tests() {
npm test
}
git_push() {
echo 'pushing to github' &&
git add package.json bower.json yuidoc.json dist &&
git commit -m 'bump to '$1 &&
git tag $1 &&
git push origin master --tags
}
upload() {
node upload.js --tag=$1 &&
node upload.js --tag=latest
}
npm_publish() {
npm publish
}
send_mail() {
last_tag=$(git log --tags --no-walk --pretty="format:%d" | sed 2q | sed 's/[()]//g' | sed 's/ tag: //' | sed -n 2p)
changelog=$(git log --pretty='%h %s (%an)\n' $last_tag..master)
message="Clappr developers bumped a new version: $1\n\nChangelog:\n=========\n$changelog\n\nwith love,\nYour happy butler.\n"
echo -e $message | mail -s "$(echo -e "[clappr] new version released: $1\nFrom: Clappr Butler <[email protected]>\n")" [email protected]
return 0
}
main() {
update_dependencies &&
update_version $1 &&
update_bower &&
build
if (("$?" != "0")); then
echo "something failed during dependency update, version update, or build"
exit 1
fi
run_tests
if (("$?" == "0")); then
git_push $1 &&
upload $1 &&
npm_publish &&
send_mail $1 &&
exit 0
echo "something failed"
exit 1
else
echo "you broke the tests. fix it before bump another version."
exit 1
fi
}
if [ "$1" != "" ]; then
main $1
else
echo "Usage: bump [new_version]"
fi