1 | #!/bin/bash
|
2 | set -eo pipefail
|
3 |
|
4 | GREEN='\033[0;32m'
|
5 | NC='\033[0m'
|
6 |
|
7 | info() {
|
8 | printf "${GREEN}$@${NC}"
|
9 | }
|
10 |
|
11 | export GIT_MERGE_AUTOEDIT=no
|
12 |
|
13 | die() {
|
14 | unset GIT_MERGE_AUTOEDIT
|
15 | echo >&2 "☠ ☠ ☠ ☠ ☠ ☠ ☠ $@ ☠ ☠ ☠ ☠ ☠ ☠ ☠"
|
16 | exit 1
|
17 | }
|
18 |
|
19 | info "Checking for vulnerabilities...\n"
|
20 |
|
21 |
|
22 | yarn run audit
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | for i in "$@"
|
30 | do
|
31 | case $i in
|
32 | -i=*|--importance=*)
|
33 | IMPORTANCE="${i#*=}"
|
34 | shift
|
35 | ;;
|
36 | *)
|
37 |
|
38 | ;;
|
39 | esac
|
40 | done
|
41 |
|
42 | if [[ -z ${IMPORTANCE:-} ]]; then
|
43 | die "Aborting the bump! Argument --importance is missing"
|
44 | fi
|
45 |
|
46 |
|
47 | if [[ `git status --porcelain` ]]; then
|
48 | die "Aborting the bump! You have uncommitted changes"
|
49 | fi
|
50 |
|
51 |
|
52 | git checkout master
|
53 | git pull
|
54 | git checkout develop
|
55 |
|
56 | read VERSION <<< $(gulp bumpVersion --importance=$IMPORTANCE | awk '/to/ {print $5}')
|
57 |
|
58 | git checkout master
|
59 | git push
|
60 | git checkout develop
|
61 | git push
|
62 |
|
63 |
|
64 | git flow release start $VERSION
|
65 |
|
66 |
|
67 | gulp bumpVersion --write --version=$VERSION
|
68 |
|
69 |
|
70 | yarn
|
71 |
|
72 |
|
73 | gulp build --minify
|
74 |
|
75 | git add -A
|
76 | git commit -m "Final commit of version $VERSION" --no-edit
|
77 |
|
78 | info "Logging to npm ...\n"
|
79 | yarn login
|
80 |
|
81 | info "Publishing to npm ...\n"
|
82 | yarn publish --new-version $VERSION
|
83 |
|
84 |
|
85 | git flow release finish $VERSION -m "Completing release of $VERSION"
|
86 |
|
87 | git push
|
88 |
|
89 | git checkout master
|
90 | git push --follow-tags
|
91 |
|
92 |
|
93 | git checkout develop
|
94 |
|
95 | unset GIT_MERGE_AUTOEDIT
|
96 |
|
97 | info "\nAll good. Ready for the next cycle!\n"
|