forked from SpinahVieh/Obsidio-Server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.bash
49 lines (39 loc) · 1.43 KB
/
deploy.bash
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
#!/usr/bin/env bash
# quick script to copy across release builds into the release branch.
# == assumes you have already run the gradle release script. ==
# == assumes you are running the repo under git.
# {}: prevents file disappearing on checkout: https://stackoverflow.com/a/2358491
# () &: without these windows refuses to checkout original branch (as deploy.bash is locked)
({
BUILDFLAVOR="$1"
if [ "$BUILDFLAVOR" == "" ]; then
echo "usage: $(basename "$0") buildflavor"
exit 0
fi
ROOT="$(realpath "$(dirname "$0")")"
# 0. save current branch, or commit if detached head
HEAD=$(git rev-parse --abbrev-ref --symbolic-full-name HEAD)
CURRENTBRANCH="$(git branch --show-current)"
if [ "$HEAD" == "$CURRENTBRANCH" ]; then
RETURNTO="$(git branch --show-current)" # on a branch
else
RETURNTO="$(git rev-parse HEAD)" # detached head
fi
# 1. change to release branch
if ! git checkout release --; then
echo "FATAL ERROR can't checkout release. quitting."
exit 2
fi
# 2. add latest to BUILDFLAVOR dir
rm -r "$ROOT"/"$BUILDFLAVOR"
mkdir "$ROOT"/"$BUILDFLAVOR"
cp -r release/* "$ROOT"/"$BUILDFLAVOR"/
# 3. apply git
git pull
git add "$ROOT"/"$BUILDFLAVOR"/
git commit -m "automatically generated release for $BUILDFLAVOR on $(date --iso-8601=s)"
git push
# 4. change back
git checkout "$RETURNTO"
exit 0
}) &