Files
dance-lessons-coach/scripts/build-with-version.sh
Gabriel Radureau 52065c9cf3
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 10s
CI/CD Pipeline / CI Pipeline (push) Failing after 13s
refactor: convert all DanceLessonsCoach mentions to kebab-case
2026-04-07 19:11:39 +02:00

43 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Build dance-lessons-coach with version information
# Usage: ./scripts/build-with-version.sh [output_path]
set -e
# Default output path
OUTPUT_PATH="${1:-bin/server}"
# Get version from VERSION file or use default
if [ -f "VERSION" ]; then
source VERSION
VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
else
VERSION="1.0.0"
fi
# Get git information
GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
GIT_DATE=$(git log -1 --format=%cd --date=short 2>/dev/null || echo "unknown")
# Build time (UTC for consistency)
BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo "🔧 Building dance-lessons-coach $VERSION"
echo " Commit: $GIT_COMMIT"
echo " Date: $GIT_DATE"
echo " Output: $OUTPUT_PATH"
# Build with ldflags to inject version information
go build \
-o "$OUTPUT_PATH" \
-ldflags="\
-X dance-lessons-coach/pkg/version.Version=$VERSION \
-X dance-lessons-coach/pkg/version.Commit=$GIT_COMMIT \
-X dance-lessons-coach/pkg/version.Date=$BUILD_DATE \
" \
./cmd/server
echo "✅ Build complete: $OUTPUT_PATH"
# Show version info
"$OUTPUT_PATH" --version 2>/dev/null || echo "Version: $VERSION"