diff --git a/main.go b/main.go index e5606c7..76e9d1c 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "github.com/jobtalk/thor/subcmd/mkelb" "github.com/jobtalk/thor/subcmd/update" "github.com/jobtalk/thor/subcmd/vault" + "github.com/jobtalk/thor/vars" "github.com/mitchellh/cli" ) @@ -33,6 +34,10 @@ func init() { } VERSION = generateBuildInfo() log.SetFlags(log.Llongfile) + + vars.VERSION = &VERSION + vars.BUILD_DATE = &BUILD_DATE + vars.BUILD_OS = &BUILD_OS } func main() { diff --git a/subcmd/update/update.go b/subcmd/update/update.go index 6cf1f20..7b34e79 100644 --- a/subcmd/update/update.go +++ b/subcmd/update/update.go @@ -9,6 +9,8 @@ import ( "os" "path/filepath" "runtime" + + "github.com/jobtalk/thor/vars" ) const ( @@ -80,6 +82,10 @@ func (c *Update) Run(args []string) int { platform = "linux-amd64" } latest := tags[0].Name + if *vars.VERSION == latest { + fmt.Println("this version is latest") + return 0 + } if latest == "" { fmt.Println("can not get latest version") return 255 diff --git a/vars/vars.go b/vars/vars.go new file mode 100644 index 0000000..96af933 --- /dev/null +++ b/vars/vars.go @@ -0,0 +1,7 @@ +package vars + +var ( + VERSION *string + BUILD_DATE *string + BUILD_OS *string +)