mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00

Although, the project says to have GO as a pre-req but having something to catch and check the dependency beforehand helps. Therefore, refactoring the script to add the check first before running to handle the script in a better way. Issue: The script does not check for Go installation before running go build. Fix: Added a dependency check to prevent build failures.
22 lines
No EOL
515 B
Bash
Executable file
22 lines
No EOL
515 B
Bash
Executable file
#!/bin/bash
|
|
|
|
# check if `go` is installed or not
|
|
if ! command -v go &> /dev/null; then
|
|
echo "Error: Go is not installed. Please install Go before running this script."
|
|
exit 1
|
|
fi
|
|
|
|
BINFILE=watchtower
|
|
if [ -n "$MSYSTEM" ]; then
|
|
BINFILE=watchtower.exe
|
|
fi
|
|
VERSION=$(git describe --tags)
|
|
echo "Building $VERSION..."
|
|
go build -o $BINFILE -ldflags "-X github.com/containrrr/watchtower/internal/meta.Version=$VERSION"
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error: Build failed!"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Build successful!" |