diff --git a/main.go b/main.go index df712b7..88efa10 100644 --- a/main.go +++ b/main.go @@ -76,6 +76,7 @@ var ( logsDirPath string feedbackBundler = utils.NewFeedbackBundler() appVersion = "v0.1.0-dev24" + buildCommit = "dev" hwAccelProbeOnce sync.Once hwAccelSupported atomic.Value // map[string]bool @@ -139,6 +140,13 @@ func statusStrip(bar *ui.ConversionStatsBar) fyne.CanvasObject { return container.NewMax(bg, content) } +func fullVersion() string { + if buildCommit == "" || buildCommit == "dev" { + return appVersion + } + return fmt.Sprintf("%s_%s", appVersion, buildCommit) +} + // moduleFooter stacks a dark status strip above a tinted action/footer band. // If content is nil, a spacer is used for consistent height/color. func moduleFooter(tint color.Color, content fyne.CanvasObject, bar *ui.ConversionStatsBar) fyne.CanvasObject { @@ -554,7 +562,7 @@ func generatePixelatedQRCode() (fyne.CanvasObject, error) { } func (s *appState) showAbout() { - version := fmt.Sprintf("VideoTools %s", appVersion) + version := fmt.Sprintf("VideoTools %s", fullVersion()) dev := "Leak Technologies" logsPath := getLogsDir() @@ -2009,7 +2017,7 @@ func (s *appState) showMainMenu() { s.updateStatsBar() // Footer with version info and a small About/Support button - versionLabel := widget.NewLabel(fmt.Sprintf("VideoTools %s", appVersion)) + versionLabel := widget.NewLabel(fmt.Sprintf("VideoTools %s", fullVersion())) versionLabel.Alignment = fyne.TextAlignLeading aboutBtn := widget.NewButton("About / Support", func() { s.showAbout() @@ -6595,7 +6603,7 @@ func main() { flag.Parse() logging.SetDebug(*debugFlag || os.Getenv("VIDEOTOOLS_DEBUG") != "") - logging.Debug(logging.CatSystem, "starting VideoTools prototype at %s", time.Now().Format(time.RFC3339)) + logging.Debug(logging.CatSystem, "starting VideoTools %s at %s", fullVersion(), time.Now().Format(time.RFC3339)) // Detect platform and configure paths cfg := DetectPlatform() // Detect and initialize platform paths locally diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index e789069..84a731d 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -9,6 +9,15 @@ BUILD_OUTPUT="$PROJECT_ROOT/VideoTools" # Extract app version from main.go (avoid grep warnings on Git Bash) APP_VERSION="$(grep -m1 'appVersion' "$PROJECT_ROOT/main.go" | sed -E 's/.*\"([^\"]+)\".*/\1/')" [ -z "$APP_VERSION" ] && APP_VERSION="(version unknown)" +GIT_COMMIT="" +if command -v git >/dev/null 2>&1; then + GIT_COMMIT="$(git -C "$PROJECT_ROOT" rev-parse --short HEAD 2>/dev/null || true)" +fi +if [ -n "$GIT_COMMIT" ]; then + FULL_VERSION="${APP_VERSION}_${GIT_COMMIT}" +else + FULL_VERSION="$APP_VERSION" +fi echo "════════════════════════════════════════════════════════════════" echo " VideoTools Build Script" @@ -78,19 +87,23 @@ if [ -d "$PROJECT_ROOT/vendor" ] && [ ! -f "$PROJECT_ROOT/vendor/modules.txt" ]; export GOFLAGS="${GOFLAGS:-} -mod=mod" fi # GStreamer is always enabled now (mandatory dependency) -if go build -tags gstreamer -o "$BUILD_OUTPUT" .; then +LDFLAGS="" +if [ -n "$GIT_COMMIT" ]; then + LDFLAGS="-X main.buildCommit=$GIT_COMMIT" +fi +if go build -tags gstreamer -ldflags="$LDFLAGS" -o "$BUILD_OUTPUT" .; then build_end=$(date +%s) build_secs=$((build_end - build_start)) - echo "Build successful! (VideoTools $APP_VERSION)" + echo "Build successful! (VideoTools $FULL_VERSION)" echo "Build time: ${build_secs}s" echo "" echo "════════════════════════════════════════════════════════════════" - echo "BUILD COMPLETE - $APP_VERSION" + echo "BUILD COMPLETE - $FULL_VERSION" echo "════════════════════════════════════════════════════════════════" echo "" echo "Output: $BUILD_OUTPUT" echo "Size: $(du -h "$BUILD_OUTPUT" | cut -f1)" - echo "Diagnostics: version=$APP_VERSION os=$(uname -s) arch=$(uname -m) go=$(go version | awk '{print $3}')" + echo "Diagnostics: version=$FULL_VERSION os=$(uname -s) arch=$(uname -m) go=$(go version | awk '{print $3}')" echo "" echo "To run:" echo " $PROJECT_ROOT/VideoTools" @@ -100,8 +113,8 @@ if go build -tags gstreamer -o "$BUILD_OUTPUT" .; then echo " VideoTools" echo "" else - echo "Build failed! (VideoTools $APP_VERSION)" - echo "Diagnostics: version=$APP_VERSION os=$(uname -s) arch=$(uname -m) go=$(go version | awk '{print $3}')" + echo "Build failed! (VideoTools $FULL_VERSION)" + echo "Diagnostics: version=$FULL_VERSION os=$(uname -s) arch=$(uname -m) go=$(go version | awk '{print $3}')" echo "" echo "Help: check the Go error messages above." echo " - Undefined symbol/identifier: usually a missing variable or typo in source; see the referenced file:line." diff --git a/scripts/build-windows.sh b/scripts/build-windows.sh index 40bbff8..60d5534 100755 --- a/scripts/build-windows.sh +++ b/scripts/build-windows.sh @@ -7,6 +7,17 @@ set -e PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" BUILD_OUTPUT="$PROJECT_ROOT/VideoTools.exe" DIST_DIR="$PROJECT_ROOT/dist/windows" +APP_VERSION="$(grep -m1 'appVersion' "$PROJECT_ROOT/main.go" | sed -E 's/.*\"([^\"]+)\".*/\1/')" +[ -z "$APP_VERSION" ] && APP_VERSION="(version unknown)" +GIT_COMMIT="" +if command -v git >/dev/null 2>&1; then + GIT_COMMIT="$(git -C "$PROJECT_ROOT" rev-parse --short HEAD 2>/dev/null || true)" +fi +if [ -n "$GIT_COMMIT" ]; then + FULL_VERSION="${APP_VERSION}_${GIT_COMMIT}" +else + FULL_VERSION="$APP_VERSION" +fi echo "════════════════════════════════════════════════════════════════" echo " VideoTools Windows Build Script (Cross-Compilation)" @@ -87,6 +98,9 @@ export CXX=x86_64-w64-mingw32-g++ # -H windowsgui: Hide console window (GUI application) # -s -w: Strip debug symbols (smaller binary) LDFLAGS="-H windowsgui -s -w" +if [ -n "$GIT_COMMIT" ]; then + LDFLAGS="$LDFLAGS -X main.buildCommit=$GIT_COMMIT" +fi if go build -ldflags="$LDFLAGS" -o "$BUILD_OUTPUT" .; then echo "Cross-compilation successful!" diff --git a/scripts/build.sh b/scripts/build.sh index 2369039..3a466c3 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -8,6 +8,15 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Extract app version from main.go (avoid grep warnings on Git Bash) APP_VERSION="$(grep -m1 'appVersion' "$PROJECT_ROOT/main.go" | sed -E 's/.*\"([^\"]+)\".*/\1/')" [ -z "$APP_VERSION" ] && APP_VERSION="(version unknown)" +GIT_COMMIT="" +if command -v git >/dev/null 2>&1; then + GIT_COMMIT="$(git -C "$PROJECT_ROOT" rev-parse --short HEAD 2>/dev/null || true)" +fi +if [ -n "$GIT_COMMIT" ]; then + FULL_VERSION="${APP_VERSION}_${GIT_COMMIT}" +else + FULL_VERSION="$APP_VERSION" +fi # Detect platform PLATFORM="$(uname -s)" @@ -36,17 +45,17 @@ go version echo "" diagnostics() { - echo "Diagnostics: version=$APP_VERSION os=$OS arch=$(uname -m) go=$(go version | awk '{print $3}')" + echo "Diagnostics: version=$FULL_VERSION os=$OS arch=$(uname -m) go=$(go version | awk '{print $3}')" } case "$OS" in Linux|macOS) - echo "→ Building VideoTools $APP_VERSION for $OS..." + echo "→ Building VideoTools $FULL_VERSION for $OS..." echo "" exec "$SCRIPT_DIR/build-linux.sh" ;; Windows) - echo "→ Building VideoTools $APP_VERSION for Windows..." + echo "→ Building VideoTools $FULL_VERSION for Windows..." echo "" cd "$PROJECT_ROOT" build_start=$(date +%s) @@ -71,22 +80,26 @@ case "$OS" in echo "GStreamer found ($(pkg-config --modversion gstreamer-1.0 2>/dev/null || echo 'version unknown'))" fi echo "" - echo "Building VideoTools $APP_VERSION for Windows..." + echo "Building VideoTools $FULL_VERSION for Windows..." export CGO_ENABLED=1 # GStreamer is always enabled (mandatory dependency on supported platforms) export GOFLAGS="${GOFLAGS:-} -tags gstreamer" if [ -d "$PROJECT_ROOT/vendor" ] && [ ! -f "$PROJECT_ROOT/vendor/modules.txt" ]; then export GOFLAGS="${GOFLAGS:-} -mod=mod" fi - if go build -ldflags="-H windowsgui -s -w" -o VideoTools.exe .; then + LDFLAGS="-H windowsgui -s -w" + if [ -n "$GIT_COMMIT" ]; then + LDFLAGS="$LDFLAGS -X main.buildCommit=$GIT_COMMIT" + fi + if go build -ldflags="$LDFLAGS" -o VideoTools.exe .; then build_end=$(date +%s) build_secs=$((build_end - build_start)) - echo "Build successful! (VideoTools $APP_VERSION)" + echo "Build successful! (VideoTools $FULL_VERSION)" echo "Build time: ${build_secs}s" echo "" if [ -f "setup-windows.bat" ]; then echo "════════════════════════════════════════════════════════════════" - echo "BUILD COMPLETE - $APP_VERSION" + echo "BUILD COMPLETE - $FULL_VERSION" echo "════════════════════════════════════════════════════════════════" echo "" echo "Output: VideoTools.exe" @@ -114,7 +127,7 @@ case "$OS" in diagnostics fi else - echo "Build failed! (VideoTools $APP_VERSION)" + echo "Build failed! (VideoTools $FULL_VERSION)" diagnostics echo "" echo "Help: check the Go error messages above."