Add sync-version

This commit is contained in:
2025-07-06 10:55:18 +00:00
parent 254db32eed
commit d60a5a944a
3 changed files with 39 additions and 9 deletions

View File

@ -10,9 +10,17 @@ GO_FILES=$(SOURCE_DIR)/main.go
.PHONY: all
all: build
# Sync version from debian/changelog to Go source
.PHONY: sync-version
sync-version:
@echo "Syncing version from debian/changelog..."
@VERSION=$$(head -1 debian/changelog | sed 's/.*(\([^)]*\)).*/\1/'); \
sed -i "s/const Version = \".*\"/const Version = \"$$VERSION\"/" $(SOURCE_DIR)/main.go; \
echo "Version synced: $$VERSION"
# Build the Go binary
.PHONY: build
build:
build: sync-version
@echo "Building $(BINARY_NAME)..."
cd $(SOURCE_DIR) && go build -o ../$(BUILD_DIR)/$(BINARY_NAME) main.go
@echo "Build complete: $(BINARY_NAME)"
@ -38,7 +46,7 @@ fmt:
# Build Debian package
.PHONY: pkg-deb
pkg-deb:
pkg-deb: sync-version build
fakeroot dpkg-buildpackage -us -uc -b
# Clean package artifacts
@ -52,10 +60,11 @@ clean-pkg:
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the router_backup binary"
@echo " clean - Remove build artifacts"
@echo " test - Run tests"
@echo " fmt - Format Go code"
@echo " pkg-deb - Create Debian package"
@echo " clean-pkg - Remove package artifacts"
@echo " help - Show this help message"
@echo " build - Build the router_backup binary"
@echo " clean - Remove build artifacts"
@echo " test - Run tests"
@echo " fmt - Format Go code"
@echo " sync-version - Sync version from debian/changelog to Go source"
@echo " pkg-deb - Create Debian package"
@echo " clean-pkg - Remove package artifacts"
@echo " help - Show this help message"