forked from swcho/ts_playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.sh
executable file
·62 lines (44 loc) · 1013 Bytes
/
dist.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
#!/bin/bash
set -e
DIST_BRANCH='gh-pages'
DIST_OUT='dist/client'
GIT_REPO_ROOT=$(git rev-parse --show-toplevel)
if [ "$GIT_REPO_ROOT" != "$PWD" ]; then
echo "Should run this script in the repository root";
exit 1;
fi
GIT_BRANCH_NAME=$(git symbolic-ref HEAD 2>/dev/null)
if [ "$GIT_BRANCH_NAME" != "refs/heads/master" ]; then
echo "Should checkout master branch";
exit 1;
fi
if [[ -n $(git status -s) ]]; then
echo "Should be clean";
exit 1;
fi
if [[ -n $(git log origin/master..master) ]]; then
echo "Should be pushed to master";
exit 1;
fi
# Update remote commits
git remote update
# Get hash
LAST_HASH=$(git rev-parse HEAD)
echo "Commit $LAST_HASH will be distributed"
# Check out to dist branch
git checkout $DIST_BRANCH
# Rebase against master
git rebase master
# Reset to last commit
git reset --hard $LAST_HASH
# Build
npm run build
# Add built files
git add $DIST_OUT
# Commit
git commit -am "Built"
# Push
git push -f
# Back to master
git checkout master
echo "FINISHED"