aboutsummaryrefslogtreecommitdiff
path: root/deploy.sh
blob: 40a81546427de6b0cf64ce2d2f57b820aebab0c2 (plain) (blame)
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
#!/bin/bash

if output=$(git status --porcelain) && [ -z "$output" ]; then
    echo "Git working directory is clean."
else
    echo "Git working directory is not clean..."
    exit 1
fi

tput setaf 4
echo "> Bump version number"
tput sgr0

if [ $# -gt 0 ]; then
    npm --no-git-tag-version version "$1" || exit 1;
else
    npm --no-git-tag-version version patch || exit 1;
fi

VERSION=$(cat package.json \
  | grep version \
  | head -1 \
  | awk -F: '{ print $2 }' \
  | sed 's/[",]//g' \
  | tr -d '[[:space:]]')
echo "Deploying for tag: $VERSION."

tput setaf 4
echo "> Build app"
tput sgr0

rm -r dist/
npm install
npm run build

tput setaf 4
echo "> Copy to gh-pages branch and commit"
tput sgr0

cp .gitignore dist/.gitignore
git checkout gh-pages || git checkout --orphan gh-pages
git rm -rf .

cp dist/.gitignore .gitignore
cp -r dist/* .

git add .
git commit -m ":rocket: Deploy app v$VERSION"

tput setaf 4
echo "> Return to controller branch and tag last commit"
tput sgr0

git checkout controller

git tag "v$VERSION"

#git push --follow-tags origin controller
git push origin "v$VERSION"
git push origin gh-pages