-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·52 lines (40 loc) · 1.16 KB
/
deploy.sh
File metadata and controls
executable file
·52 lines (40 loc) · 1.16 KB
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
#!/bin/bash
if [[ -z $PUBLIC_REPO ]]; then
echo "[CD] No public repository set, exiting deploy"
exit 0
fi
if [[ ! $PUBLIC_REPO =~ ^git@.+:.+\/.+\.git$ ]]; then
echo "[CD] Public repository needs to be an ssh url"
exit 1
fi
echo "[CD] Add Remote"
git remote add public $PUBLIC_REPO
git fetch public
echo "[CD] Create New Release Branch"
# If the remote master exists, check it out
# otherwise just use the tag to start with
if [[ $(git branch -a | grep public/master) ]]; then
git checkout public/master
fi
git checkout -b release
echo "[CD] Merge the Tag"
git merge --strategy-option theirs --squash $TRAVIS_TAG --allow-unrelated-histories
echo "[CD] Remove non-release items"
git rm -rf test
git rm -f .travis.yml
git rm -f .gitignore
git rm -f go.*
git rm -f "$0"
echo "[CD] Commit"
git commit -m "$TRAVIS_TAG release"
# Reset the root if new repository
if [[ ! $(git branch -a | grep public/master) ]]; then
git reset $(git commit-tree HEAD^{tree} -m "$TRAVIS_TAG release")
fi
echo "[CD] Push to Remote Master"
git push public release:master
echo "[CD] Make Public Tag"
git tag -d $TRAVIS_TAG
git tag $TRAVIS_TAG
git push public $TRAVIS_TAG
echo "[CD] Done"