Skip to content

Commit

Permalink
Merge pull request #37 from roma-glushko/27-specify-version-from-ci
Browse files Browse the repository at this point in the history
#27 Pass application version from CI
  • Loading branch information
roma-glushko authored Feb 16, 2020
2 parents 4c450a6 + f08bcee commit c327ed8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ builds:
- amd64
- arm
- arm64
ldflags:
- "-s -w -X main.version={{.Version}}"

archives:
-
Expand Down
14 changes: 12 additions & 2 deletions internal/cli/tango-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"log"
"runtime/debug"
"tango/internal/cli/command"
"tango/internal/cli/component"
"time"
Expand Down Expand Up @@ -183,9 +184,9 @@ func NewTangoCli() TangoCli {

cliApp.Name = "Tango"
cliApp.Usage = "Access Logs Analyzing Tool"
cliApp.Version = "1.0.3 [beta]"
cliApp.Version = GetVersion()
cliApp.Compiled = time.Now()
cliApp.Copyright = "(c) 2019 Roman Glushko"
cliApp.Copyright = "(c) 2019-2020 Roman Glushko"
cliApp.Authors = []cli.Author{
cli.Author{
Name: "Roman Glushko",
Expand All @@ -203,6 +204,15 @@ func NewTangoCli() TangoCli {
}
}

// Get Application Version
func GetVersion() string {
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" {
return info.Main.Version
}

return "develop"
}

// Run executes Tango CLI Application
func (app *TangoCli) Run(arguments []string) {
err := app.cliApp.Run(arguments)
Expand Down

0 comments on commit c327ed8

Please sign in to comment.