UNPKG

1.93 kBapplication/x-shView Raw
1#!/bin/bash
2set -eo pipefail
3
4GREEN='\033[0;32m'
5NC='\033[0m' # No Color
6
7info() {
8 printf "${GREEN}$@${NC}"
9}
10
11export GIT_MERGE_AUTOEDIT=no
12
13die() {
14 unset GIT_MERGE_AUTOEDIT
15 echo >&2 "☠ ☠ ☠ ☠ ☠ ☠ ☠ $@ ☠ ☠ ☠ ☠ ☠ ☠ ☠"
16 exit 1
17}
18
19info "Checking for vulnerabilities...\n"
20
21# thanks to set -e it will exit here if audit fails
22yarn run audit
23
24# todo: figure out an elegant solution to avoid duplicate code
25# when having three bash scripts for patches, features and releases
26# maybe with command line args?
27# when done, rename this file
28
29for i in "$@"
30do
31case $i in
32 -i=*|--importance=*)
33 IMPORTANCE="${i#*=}"
34 shift # past argument=value
35 ;;
36 *)
37 # unknown option
38 ;;
39esac
40done
41
42if [[ -z ${IMPORTANCE:-} ]]; then
43 die "Aborting the bump! Argument --importance is missing"
44fi
45
46# ensures all is commited
47if [[ `git status --porcelain` ]]; then
48 die "Aborting the bump! You have uncommitted changes"
49fi
50
51# Ensures master is up to date
52git checkout master
53git pull
54git checkout develop
55
56read VERSION <<< $(gulp bumpVersion --importance=$IMPORTANCE | awk '/to/ {print $5}')
57
58git checkout master
59git push
60git checkout develop
61git push
62
63# Start a new release
64git flow release start $VERSION
65
66# This will increment version in package.json
67gulp bumpVersion --write --version=$VERSION
68
69# Ensure dependencies are okay
70yarn
71
72# Rebuild all assets
73gulp build --minify
74
75git add -A
76git commit -m "Final commit of version $VERSION" --no-edit
77
78info "Logging to npm ...\n"
79yarn login
80
81info "Publishing to npm ...\n"
82yarn publish --new-version $VERSION
83
84# Complete the previous release
85git flow release finish $VERSION -m "Completing release of $VERSION" # This will also tag it
86
87git push
88
89git checkout master
90git push --follow-tags
91
92# Prepare the develop branch for the new cycle
93git checkout develop
94
95unset GIT_MERGE_AUTOEDIT
96
97info "\nAll good. Ready for the next cycle!\n"