-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
49 lines (40 loc) · 1.31 KB
/
install.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
#!/bin/bash
# install gitlab-flow2 with gitlab application(appId, appSecret)
# replace follow variables with your personal parameters,
# or export them into ENV variables.
# APP_ID=__YOUR_APP_ID__
# APP_SECRET=__YOUR_APP_SECRET__
#
#
# Usage:
# APP_ID=gitlab_app_id APP_SECRET=gitlab_app_secret BIN=gitlab-flow ./install.sh
if [ -z "${APP_ID}" ]; then
echo "Empty APP_ID, !!!replace your APP_ID at first"
exit 1
fi
if [ -z "${APP_SECRET}" ]; then
echo "Empty APP_SECRET, !!!replace your APP_SECRET at first"
exit 1
fi
if [ -z "${BIN}" ]; then
echo "Empty BIN, using default name: gitlab-flow"
BIN="gitlab-flow"
fi
# echo build info and start compiling
echo "Start compiling..."
echo "APP_ID=${APP_ID}"
echo "APP_SECRET=${APP_SECRET}"
echo "BIN=${BIN}"
go build \
-o "${BIN}" \
-ldflags="-X 'github.com/yeqown/gitlab-flow/internal/gitlab-operator.OAuth2AppID=${APP_ID}' \
-X 'github.com/yeqown/gitlab-flow/internal/gitlab-operator.OAuth2AppSecret=${APP_SECRET}'" \
./cmd/gitlab-flow
# check if compiled successfully, then install it
echo "Compiled successfully, start installing..."
GOBIN=$(go env GOBIN)
if [ -z "${GOBIN}" ]; then
echo "Empty GOBIN, installing stopped, please check your go env or move the binary to your PATH manually"
fi
echo "Install ${BIN} to ${GOBIN}"
mv "${BIN}" "${GOBIN}"