-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbump.sh
executable file
·50 lines (41 loc) · 1.03 KB
/
bump.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
#!/bin/bash
function bump_bower {
search='\("version"\s*:\s*"\).\+\("\)'
replace="\1${version}\2"
sed -i".tmp" -e"s/${search}/${replace}/g" "$1"
rm "$1.tmp"
}
function bump_js {
search='\(@version\s*\).\+$'
replace="\1${version}"
sed -i".tmp" -e"s/${search}/${replace}/g" "$1"
rm "$1.tmp"
}
function help {
echo "Usage: $(basename $0) [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]"
}
if [ -z "$1" ] || [ "$1" = "help" ]; then
help
exit
fi
release=$1
if [ -d ".git" ]; then
changes=$(git status --porcelain)
if [ -z "${changes}" ]; then
output=$(npm version ${release} --no-git-tag-version)
version=${output:1}
bump_bower "bower.json"
bump_js "index.js"
npm run build
git add .
git commit -m "Bump to ${version}"
npm publish ./
else
echo "Please commit staged files prior to bumping"
fi
else
output=$(npm version ${release} --no-git-tag-version)
version=${output:1}
bump_bower "bower.json"
bump_js "index.js"
fi