-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
67 lines (54 loc) · 1.17 KB
/
deploy.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
66
67
# Make sure we are on the dev branch
branch=$(git branch --show-current)
if [ "$branch" = 'dev' ]; then :
else
echo "Wrong branch [$branch]"
exit 1
fi
# Make sure there are no uncommitted changes
status=$(git status --porcelain)
if [ -n "$status" ]; then
echo 'Commit changes first'
exit 1
fi
# Get version level if not already specified
if [ -z "$1" ]; then
echo 'Version level? [patch, minor, major]'
read level
else
level="$1"
fi
# Check if version level is valid
if [[ ' patch minor major ' == *" $level "* ]]; then :
else
echo "Invalid version level [$level]"
exit 1
fi
# Increment app version and commmit
npm version "$level"
# Push dev branch
echo ''
echo 'Pushing dev branch'
git push origin dev
# Switch to master branch
echo ''
git checkout master
# Make sure we are on the master branch
branch=$(git branch --show-current)
if [ "$branch" = 'master' ]; then :
else
echo "Wrong branch [$branch]"
exit 1
fi
# Merge dev branch into master
echo ''
echo 'Merging dev into master'
git merge dev
# Push master branch
echo ''
echo 'Pushing master branch'
git push origin master
# Switch back to dev branch
echo ''
git checkout dev
echo ''