-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·78 lines (63 loc) · 1.54 KB
/
release.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
API_REPO_NAME="onezone"
# Code bellow should not modified,
# all the customized is placed above this comment
usage() { cat <<EOF
Usage: release.sh -m <commit-message> [-b <branch-name>]
This commits files generated here to a target repo.
Example usage:
sr-publish -m "major changes!" -b master
Options:
-h,--help This help message
-b,--branch Branch name in a target repo
-m,--message Commit message that will be seen in a target repo
EOF
}
# default values
DOC_BRANCH="develop"
while (( $# )) ; do
flag=$1
case $flag in
-b|--branch)
DOC_BRANCH=$2
shift
;;
-m|--message)
commit_message=$2
shift
;;
-h|--help)
usage
exit 0
shift
;;
*)
echo "no opntion ${flag}"
exit 1
;;
esac
shift
done
if [[ -z ${commit_message} ]] ; then
echo "Must specify commit message with '-m' option. Lets keep git-log clean!"
exit 1
fi
REPO_NAME=onedata-documentation
TMP_DIR=$(mktemp -d)
git_c="git -C $TMP_DIR"
$git_c clone --single-branch -b $DOC_BRANCH ssh://[email protected]:7999/vfs/${REPO_NAME}.git ${TMP_DIR}
SRC_GITBOOK=generated/gitbook
PATH_IN_GITBOOK=${TMP_DIR}/doc/advanced/rest/${API_REPO_NAME}
$git_c rm -r $PATH_IN_GITBOOK/*
mkdir -p $PATH_IN_GITBOOK
cp -r $SRC_GITBOOK/* $PATH_IN_GITBOOK/
SRC_SWAGGER=swagger.json
PATH_IN_GITBOOK=${TMP_DIR}/doc/swagger/${API_REPO_NAME}
$git_c rm -r $PATH_IN_GITBOOK/*
mkdir -p $PATH_IN_GITBOOK
#cp -r $SRC_SWAGGER $PATH_IN_GITBOOK/
$git_c add -A
$git_c diff
$git_c commit -m "${API_REPO_NAME} swag. api: $commit_message"
$git_c push
rm -rf $TMP_DIR