forked from jippi/hashi-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_dev.sh
executable file
·48 lines (33 loc) · 1.14 KB
/
build_dev.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
#! /usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
GIT_COMMIT="$(git describe --tags)"
GIT_DIRTY=""
if [ -n "$(git status --porcelain)" ]; then
GIT_DIRTY=",+CHANGES"
fi
GO_LDFLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}"
GOBUILD="$(go env GOOS)"-"$(go env GOARCH)"
BINNAME=hashi-ui-"${GOBUILD}"
BUILDNAME="${DIR}/backend/build/${BINNAME}"
rm -rf ${DIR}/frontend/dist
rm -rf ${DIR}/frontend/build
echo "=> building frontend .."
cd ${DIR}/frontend
yarn install --mutex file
yarn run build
cd ${DIR}/backend
rm -rf ${DIR}/backend/build
find ${DIR}/backend/vendor/* -type d -exec rm -rf {} +
rm ${DIR}/backend/bindata_assetfs.go
echo "=> loading build dependencies ..."
go get -u github.com/golang/dep/cmd/dep
go get -u github.com/jteeuwen/go-bindata/...
go get -u github.com/elazarl/go-bindata-assetfs/...
go get github.com/mitchellh/go-ps
echo "=> dep ensure -vendor-only ..."
dep ensure -vendor-only sync
echo "=> packaging assets ..."
go-bindata-assetfs -prefix ${DIR}/frontend ${DIR}/frontend/build/...
echo "=> building ${BUILDNAME} ..."
CGO_ENABLED=0 go build -o "${BUILDNAME}" -ldflags "${GO_LDFLAGS}"
echo "=> done"