Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Error Handling and Dependency Checks in build.sh file #2083

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
#!/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!"