From bd8537a334bb5fbbc1292fa75b18112b2c4096e8 Mon Sep 17 00:00:00 2001 From: Valentin Doreau Date: Fri, 1 Nov 2024 19:34:36 +0100 Subject: [PATCH] chore: support adding version at build time --- Makefile | 6 +++--- app_exporter.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d368953..415e2b2 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ .PHONY: all build clean -PROJECT_NAME = $(shell head -n1 go.mod | cut -d'/' -f2) - +PROJECT_NAME = $(shell head -n1 go.mod | cut -d'/' -f2) +VERSION ?= dev all: build # Build static executable build: - CGO_ENABLED=0 go build + CGO_ENABLED=0 go build -ldflags "-X main.VERSION=${VERSION}" strip $(PROJECT_NAME) clean: diff --git a/app_exporter.go b/app_exporter.go index ef46d36..44875ff 100644 --- a/app_exporter.go +++ b/app_exporter.go @@ -13,7 +13,8 @@ import ( "recycled.cloud/app-exporter/apps" ) -const VERSION = "0.1.0" +// var so it can be overridden at build time +var VERSION = "dev" const LISTEN_ADDR = ":9404" const INTERVAL = 24 * time.Hour