-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathscripts.sh
executable file
·74 lines (65 loc) · 1.18 KB
/
scripts.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
#!/bin/sh
# Exit on first failure.
set -e
test_go() {
echo "testing"
# make some files for embed
mkdir -p ./frontend/build
touch ./frontend/build/index.html
go test ./...
}
build_frontend() {
echo "building frontend"
mkdir -p ./build
root=$(pwd)
if [ -n "$FUSION_VERSION" ]; then
version="$FUSION_VERSION"
else
# Try to get version relative to the last git tag.
if git describe --tags --abbrev=0 >/dev/null 2>&1; then
version=$(git describe --tags --abbrev=0)
else
# If repo has no tags, just use the latest commit hash.
version=$(git rev-parse --short HEAD)
fi
fi
echo "Using fusion version string: ${version}"
cd ./frontend
pnpm i
VITE_FUSION_VERSION="$version" pnpm run build
cd $root
}
build_backend() {
echo "building backend"
CGO_ENABLED=0 go build \
-ldflags '-extldflags "-static"' \
-o ./build/fusion \
./cmd/server/*
}
build() {
test_go
build_frontend
build_backend
}
dev() {
go run \
-ldflags '-extldflags "-static"' \
./cmd/server
}
case $1 in
"test")
test_go
;;
"dev")
dev
;;
"build-frontend")
build_frontend
;;
"build-backend")
build_backend
;;
"build")
build
;;
esac