From 80be4afeda070063ff9e7cbbd2b2aaad44f820dd Mon Sep 17 00:00:00 2001 From: Andy Librian Date: Sat, 13 Mar 2021 12:14:54 +0700 Subject: [PATCH] Add version information --- .goreleaser.yml | 9 +++++++++ cmd/terjang/main.go | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index bb78c0c..aa8f553 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -10,6 +10,9 @@ builds: - windows - darwin main: ./cmd/terjang/main.go + mod_timestamp: '{{ .CommitTimestamp }}' + ldflags: + - -X main.version={{.Version}} -X main.commit={{.Commit}} checksum: name_template: 'checksums.txt' snapshot: @@ -20,3 +23,9 @@ changelog: exclude: - '^docs:' - '^test:' + - Merge pull request + - Merge branch +archives: + - format_overrides: + - goos: windows + format: zip diff --git a/cmd/terjang/main.go b/cmd/terjang/main.go index 304f805..6c99fa6 100644 --- a/cmd/terjang/main.go +++ b/cmd/terjang/main.go @@ -10,6 +10,12 @@ import ( "go.uber.org/zap" ) +// nolint: gochecknoglobals +var ( + version = "dev" + commit = "main" +) + func main() { app := getCliApp() @@ -21,8 +27,9 @@ func main() { func getCliApp() *cli.App { return &cli.App{ - Name: "Terjang", - Usage: "A scalable HTTP load testing tool built on Vegeta.", + Name: "Terjang", + Usage: "A scalable HTTP load testing tool built on Vegeta.", + Version: version + " (" + commit + ")", Flags: []cli.Flag{ &cli.StringFlag{ Name: "log-level",