Skip to content

Commit

Permalink
add build script for various platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
sagostin committed Jul 12, 2024
1 parent bda8af7 commit f8c36b8
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Set the name of your application
APP_NAME="netwatcher-agent"

# Set the path of your main.go file
MAIN_PATH="./"

# Create a bin directory
mkdir -p bin

# Build for macOS (amd64 and arm64)
GOOS=darwin GOARCH=amd64 go build -o bin/${APP_NAME}-darwin-amd64 ${MAIN_PATH}
GOOS=darwin GOARCH=arm64 go build -o bin/${APP_NAME}-darwin-arm64 ${MAIN_PATH}

# Build for Linux (amd64 and arm64)
GOOS=linux GOARCH=amd64 go build -o bin/${APP_NAME}-linux-amd64 ${MAIN_PATH}
GOOS=linux GOARCH=arm64 go build -o bin/${APP_NAME}-linux-arm64 ${MAIN_PATH}

# Build for Windows (amd64 and 386)
GOOS=windows GOARCH=amd64 go build -o bin/${APP_NAME}-windows-amd64.exe ${MAIN_PATH}
GOOS=windows GOARCH=386 go build -o bin/${APP_NAME}-windows-386.exe ${MAIN_PATH}

# Create ZIP archives for each release
cd bin
for file in *; do
if [ -f "$file" ]; then
zip "${file}.zip" "$file"
rm "$file"
fi
done
cd ..

echo "Build complete. Release files are in the 'bin' directory."

0 comments on commit f8c36b8

Please sign in to comment.