-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·54 lines (42 loc) · 1.34 KB
/
build.sh
File metadata and controls
executable file
·54 lines (42 loc) · 1.34 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
#!/bin/bash
set -e
# Configuration
VERSION=${VERSION:-"1.0.0"}
COMMIT=${COMMIT:-$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")}
BUILD_DATE=${BUILD_DATE:-$(date -u +%Y-%m-%dT%H:%M:%SZ)}
OUTPUT_DIR="bin"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}Building Vulnetix CLI v${VERSION}${NC}"
# Create output directory
mkdir -p $OUTPUT_DIR
# Build targets
TARGETS=(
"linux/amd64"
"linux/arm64"
"darwin/amd64"
"darwin/arm64"
"windows/amd64"
"windows/arm64"
)
# Build for each target
for target in "${TARGETS[@]}"; do
IFS='/' read -r GOOS GOARCH <<< "$target"
echo -e "${YELLOW}Building for ${GOOS}/${GOARCH}...${NC}"
# Set output filename
output_name="vulnetix-${GOOS}-${GOARCH}"
if [[ $GOOS == "windows" ]]; then
output_name="${output_name}.exe"
fi
# Build
CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build \
-ldflags "-s -w -X github.com/vulnetix/cli/cmd.version=${VERSION} -X github.com/vulnetix/cli/cmd.commit=${COMMIT} -X github.com/vulnetix/cli/cmd.buildDate=${BUILD_DATE}" \
-o "${OUTPUT_DIR}/${output_name}" \
.
echo -e "${GREEN}✓ Built ${output_name}${NC}"
done
echo -e "${GREEN}Build complete! Binaries are in the ${OUTPUT_DIR}/ directory${NC}"
ls -la $OUTPUT_DIR/