-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·31 lines (23 loc) · 1.04 KB
/
build.sh
File metadata and controls
executable file
·31 lines (23 loc) · 1.04 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
#!/bin/bash
# verbose
set -ex
# setup vars
BUILD_VERSION=$(git describe --tags --abbrev=0 --match "v*" | cut -dv -f2)
WORKING_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
OUTPUT_DIR="${WORKING_DIR}/dist"
COMMANDS=$(ls ${WORKING_DIR}/cmd)
PLUGINS=$(ls ${WORKING_DIR}/plugins)
LDFLAGS="-X main.Build=${BUILD_VERSION}"
# reset output dir
rm -rf ${OUTPUT_DIR} > /dev/null 2>&1
mkdir -p ${OUTPUT_DIR}/web ${OUTPUT_DIR}/plugins
# go environment
(cd ${WORKING_DIR} && go version)
# run tests
(cd ${WORKING_DIR} && go test ./internal/pkg/... && go test ./pkg/...)
# build commands
(cd ${WORKING_DIR} && for item in ${COMMANDS}; do go build -ldflags "${LDFLAGS}" -o dist/$item cmd/$item/$item.go; done)
# build plugins
(cd ${WORKING_DIR} && for item in ${PLUGINS}; do go build -buildmode=plugin -ldflags "${LDFLAGS}" -o dist/plugins/$item.so plugins/$item/$item.go; done)
# build web
(cd ${WORKING_DIR}/web && rm -rf node_modules > /dev/null 2>&1 && corepack enable && pnpm install --frozen-lockfile --ignore-scripts && pnpm run build)