From 03a24da285247e2bed7bbd7a671454c3f8440f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20M=C3=BCnch?= Date: Fri, 10 May 2024 21:17:46 +0200 Subject: [PATCH] set version in github release and print it (#57) Signed-off-by: Malte Muench Co-authored-by: Malte Muench --- .github/workflows/release.yaml | 1 + src/main.go | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3663b96..ec62814 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -24,5 +24,6 @@ jobs: binary_name: can2mqtt compress_assets: false project_path: src + ldflags: -X "main.version=${{ vars.GITHUB_REF_NAME }}" env: CGO_ENABLED: 0 diff --git a/src/main.go b/src/main.go index f181185..ab4acf7 100644 --- a/src/main.go +++ b/src/main.go @@ -13,12 +13,15 @@ import ( "sync" ) -var pairFromID map[uint32]*can2mqtt // c2m pair (lookup from ID) -var pairFromTopic map[string]*can2mqtt // c2m pair (lookup from Topic) -var debugLog bool -var canInterface, mqttConnection, configFile string -var dirMode = 0 // directional modes: 0=bidirectional 1=can2mqtt only 2=mqtt2can only [-d] -var wg sync.WaitGroup +var ( + pairFromID map[uint32]*can2mqtt // c2m pair (lookup from ID) + pairFromTopic map[string]*can2mqtt // c2m pair (lookup from Topic) + debugLog bool + canInterface, mqttConnection, configFile string + version = "dev" + dirMode = 0 // directional modes: 0=bidirectional 1=can2mqtt only 2=mqtt2can only [-d] + wg sync.WaitGroup +) func main() { log.SetFlags(0) @@ -38,7 +41,7 @@ func main() { slog.SetLogLoggerLevel(slog.LevelDebug) } - slog.Info("Starting can2mqtt", "mqtt-config", mqttConnection, "can-interface", canInterface, "can2mqtt.csv", configFile, "dir-mode", dirMode, "debug", debugLog) + slog.Info("Starting can2mqtt", "version", version, "mqtt-config", mqttConnection, "can-interface", canInterface, "can2mqtt.csv", configFile, "dir-mode", dirMode, "debug", debugLog) wg.Add(1) go canStart(canInterface) // epic parallel shit ;-) mqttStart(mqttConnection)