-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·36 lines (26 loc) · 1.07 KB
/
build.sh
File metadata and controls
executable file
·36 lines (26 loc) · 1.07 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
#!/bin/bash
set -e
# Build directory
BUILD_DIR="build"
mkdir -p $BUILD_DIR
# Version
VERSION="1.0.0"
BUILD_TIME=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Build flags
LDFLAGS="-s -w -X 'main.Version=$VERSION' -X 'main.BuildTime=$BUILD_TIME' -X 'main.CommitHash=$COMMIT_HASH'"
echo "Building Procman v$VERSION..."
# Build for current platform
echo "Building for $(go env GOOS)/$(go env GOARCH)..."
go build -ldflags="$LDFLAGS" -o $BUILD_DIR/procman ./cmd/procman
# Build for Linux
echo "Building for linux/amd64..."
GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o $BUILD_DIR/procman-linux-amd64 ./cmd/procman
# Build for Windows
echo "Building for windows/amd64..."
GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -o $BUILD_DIR/procman-windows-amd64.exe ./cmd/procman
# Build for macOS
echo "Building for darwin/amd64..."
GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -o $BUILD_DIR/procman-darwin-amd64 ./cmd/procman
echo "Build completed! Binaries are in the $BUILD_DIR directory"
ls -la $BUILD_DIR/