-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·68 lines (57 loc) · 1.5 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·68 lines (57 loc) · 1.5 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
#!/bin/bash
# Build script for prom2sar CLI
set -e
VERSION="1.0.0"
BUILD_DIR="./bin"
DIST_DIR="./dist"
echo "=== Building prom2sar v${VERSION} ==="
# Create directories
mkdir -p "$BUILD_DIR"
mkdir -p "$DIST_DIR"
# Build for current platform
echo "Building for current platform..."
go build -o "${BUILD_DIR}/prom2sar" cmd/prom2sar/main.go
echo "✓ Built: ${BUILD_DIR}/prom2sar"
# Build for common platforms
echo ""
echo "Building release binaries..."
# Linux AMD64
echo "- Linux AMD64..."
GOOS=linux GOARCH=amd64 go build \
-ldflags "-X main.version=${VERSION}" \
-o "${DIST_DIR}/prom2sar-linux-amd64" \
cmd/prom2sar/main.go
# Linux AMD64 (static)
echo "- Linux AMD64 (static)..."
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "-X main.version=${VERSION} -extldflags '-static'" \
-o "${DIST_DIR}/prom2sar-linux-amd64-static" \
cmd/prom2sar/main.go
# Linux ARM64
echo "- Linux ARM64..."
GOOS=linux GOARCH=arm64 go build \
-ldflags "-X main.version=${VERSION}" \
-o "${DIST_DIR}/prom2sar-linux-arm64" \
cmd/prom2sar/main.go
# Create checksums
echo ""
echo "Creating checksums..."
cd "$DIST_DIR"
sha256sum prom2sar-* > checksums.txt
cd - > /dev/null
# Display results
echo ""
echo "=== Build Complete ==="
echo ""
echo "Binaries:"
ls -lh "${DIST_DIR}"/prom2sar-*
echo ""
echo "Checksums:"
cat "${DIST_DIR}/checksums.txt"
echo ""
echo "Test the binary:"
echo " ${BUILD_DIR}/prom2sar --version"
echo ""
echo "Install system-wide:"
echo " sudo cp ${BUILD_DIR}/prom2sar /usr/local/bin/"
echo ""