From 733b3222b397ddf57cc614ece83bc5ad9d7c5d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 12 Jun 2025 13:29:46 +0200 Subject: [PATCH] Get version from ldflags --- Makefile | 4 ++-- main.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b58dbd6..38e679a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ NAME = $(notdir $(PWD)) VERSION = $(shell git describe --tags --abbrev=0) - +COMMIT = $(shell git rev-parse HEAD) GO111MODULE = on REMOTE = kovetskiy @@ -15,7 +15,7 @@ get: build: @echo :: building go binary $(VERSION) CGO_ENABLED=0 go build \ - -ldflags "-X main.version=$(VERSION)" \ + -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT)" \ -gcflags "-trimpath $(GOPATH)/src" test: diff --git a/main.go b/main.go index 7827971..ac06d2f 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "os" "github.com/kovetskiy/mark/util" @@ -9,8 +10,13 @@ import ( "github.com/urfave/cli/v3" ) + +var ( + version = "dev" + commit = "none" +) + const ( - version = "14.0.2" usage = "A tool for updating Atlassian Confluence pages from markdown." description = `Mark is a tool to update Atlassian Confluence pages from markdown. Documentation is available here: https://github.com/kovetskiy/mark` ) @@ -20,7 +26,7 @@ func main() { Name: "mark", Usage: usage, Description: description, - Version: version, + Version: fmt.Sprintf("%s@%s", version, commit), Flags: util.Flags, EnableShellCompletion: true, HideHelpCommand: true,