-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·95 lines (78 loc) · 2.24 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·95 lines (78 loc) · 2.24 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
set -e
# Configurable build variables
BINARY_NAME="dingwave"
BUILD_DIR="releases"
# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Platform targets
PLATFORMS=(
"windows/386"
"windows/amd64"
"darwin/amd64"
"darwin/arm64"
"linux/386"
"linux/amd64"
)
echo -e "${BLUE}=== DingTalk Exporter Build Script ===${NC}"
echo -e "${BLUE}Binary name: ${BINARY_NAME}${NC}\n"
# Prerequisites check
echo -e "${YELLOW}Checking prerequisites...${NC}"
if ! command -v pnpm &> /dev/null; then
echo -e "${RED}Error: pnpm is not installed${NC}"
exit 1
fi
if ! command -v go &> /dev/null; then
echo -e "${RED}Error: go is not installed${NC}"
exit 1
fi
echo -e "${GREEN}✓ Prerequisites check passed${NC}\n"
# Clean and prepare build directory
echo -e "${YELLOW}Preparing build directory...${NC}"
rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
echo -e "${GREEN}✓ Build directory ready${NC}\n"
# Frontend build phase
echo -e "${BLUE}=== Building Frontend ===${NC}"
cd frontend/
pnpm install
pnpm build
cd ..
if [ ! -d "server/dist" ]; then
echo -e "${RED}Error: Frontend build failed - server/dist not found${NC}"
exit 1
fi
echo -e "${GREEN}✓ Frontend build completed${NC}\n"
# Backend cross-compilation phase
echo -e "${BLUE}=== Building Backend for Multiple Platforms ===${NC}"
cd server/
for platform in "${PLATFORMS[@]}"; do
IFS='/' read -r os arch <<< "$platform"
output_name="${BINARY_NAME}-${os}-${arch}"
if [ "$os" = "windows" ]; then
output_name="${output_name}.exe"
fi
echo -e "${YELLOW}Building for ${os}/${arch}...${NC}"
GOOS=${os} GOARCH=${arch} go build \
-ldflags "-s -w" \
-trimpath \
-o "../${BUILD_DIR}/${output_name}" \
main.go
echo -e "${GREEN}✓ Built ${output_name}${NC}"
done
cd ..
# Display build summary
echo -e "\n${BLUE}=== Build Summary ===${NC}"
echo -e "${GREEN}All builds completed successfully!${NC}\n"
echo -e "Build artifacts in ${BUILD_DIR}/:"
for file in "${BUILD_DIR}"/*; do
if [ -f "$file" ]; then
size=$(du -h "$file" | cut -f1)
echo -e " ${BLUE}$(basename "$file")${NC} (${size})"
fi
done
echo -e "\n${GREEN}Build complete!${NC}"