From 97a1bc503903b851010da015aa60db32a1a00a2e Mon Sep 17 00:00:00 2001 From: Muhammed Can Kucukaslan Date: Sat, 30 Sep 2023 15:21:52 +0300 Subject: [PATCH] yet another attempt to inject version --- .goreleaser.yml | 4 ---- main.go | 10 ++++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index aff8437..8d79f3e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,10 +1,6 @@ -before: - hooks: - - go build -ldflags "-s -w -X main.Version={{.Tag}} -X main.GitCommit={{ .ShortCommit }}" builds: - binary: todo - ldflags: -s -w -X main.Version={{.Tag}} -X main.GitCommit={{ .ShortCommit }} env: - CGO_ENABLED=0 goos: diff --git a/main.go b/main.go index 9bbea34..bfec75e 100644 --- a/main.go +++ b/main.go @@ -18,10 +18,12 @@ import ( var ( // Version represents the git tag of a particular release. - Version = "v0.0.0" + version = "v0.0.0" // GitCommit represents git commit hash of a particular release. - GitCommit = "dev" + commit = "dev" + date = "" + builtBy = "" ) func main() { @@ -71,7 +73,7 @@ func main() { } func printVersion() { - v := Version + "-" + GitCommit - fmt.Println("todo ", v, " (by Muhammed Can Küçükaslan https://github.com/kucukaslan)\nYou're currently using the version ", v) + v := version + "-" + commit + fmt.Println("todo ", v, " built on", date," (by Muhammed Can Küçükaslan https://github.com/kucukaslan)") fmt.Println("There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") }