feat: add version package to hold application version for build time configuration

This commit is contained in:
Abhinav Raut
2025-06-14 21:48:55 +05:30
parent 60c89cb617
commit 6a77d346dc
2 changed files with 8 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ frontend-build: install-deps
.PHONY: run-backend .PHONY: run-backend
run-backend: run-backend:
@echo "→ Running backend..." @echo "→ Running backend..."
CGO_ENABLED=0 go run -ldflags="-s -w -X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}' -X 'main.frontendDir=frontend/dist'" cmd/*.go CGO_ENABLED=0 go run -ldflags="-s -w -X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}' -X 'github.com/abhinavxd/libredesk/internal/version.Version=${VERSION}' -X 'main.frontendDir=frontend/dist'" cmd/*.go
# Run the JS frontend server in development mode. # Run the JS frontend server in development mode.
.PHONY: run-frontend .PHONY: run-frontend
@@ -52,8 +52,8 @@ run-frontend:
.PHONY: build-backend .PHONY: build-backend
build-backend: $(STUFFBIN) build-backend: $(STUFFBIN)
@echo "→ Building backend..." @echo "→ Building backend..."
@CGO_ENABLED=0 go build -a\ @CGO_ENABLED=0 go build -a \
-ldflags="-X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}' -s -w" \ -ldflags="-X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}' -X 'github.com/abhinavxd/libredesk/internal/version.Version=${VERSION}' -s -w" \
-o ${BIN} cmd/*.go -o ${BIN} cmd/*.go
# Main build target: builds both frontend and backend, then stuffs static assets into the binary. # Main build target: builds both frontend and backend, then stuffs static assets into the binary.

View File

@@ -0,0 +1,5 @@
package version
// Version holds the current version of the application.
// This value is intended to be set at build time using the -X linker flag.
var Version = "unknown-version"