From 00129dd1c199bac04df20ba5e819695812216102 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Fri, 7 Jul 2017 23:23:31 +0200 Subject: [PATCH] V1.0.0 alpha3 dev (#12) Using version ldflag provided by GoReleaser --- commands/version.go | 7 +++---- notifier/notifier.go | 2 +- orbit.go | 11 +++++++++++ version/version.go | 8 ++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 version/version.go diff --git a/commands/version.go b/commands/version.go index f4cff4c..df23ad7 100644 --- a/commands/version.go +++ b/commands/version.go @@ -3,13 +3,12 @@ package commands import ( "fmt" + OrbitVersion "github.com/gulien/orbit/version" + "github.com/spf13/cobra" ) var ( - // version is the current version of Orbit. - version = "1.0.0-alpha1" - // versionCmd is the instance of version command. versionCmd = &cobra.Command{ Use: "version", @@ -17,7 +16,7 @@ var ( SilenceUsage: true, SilenceErrors: true, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("v" + version) + fmt.Println(OrbitVersion.Current) }, } ) diff --git a/notifier/notifier.go b/notifier/notifier.go index 71aa1bd..7826122 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -37,7 +37,7 @@ func newOrbitNotifier() *OrbitNotifier { } } -// Houston contains the OrbitNotifier instance used by the application. +// Houston is the OrbitNotifier instance used by the application. var Houston = newOrbitNotifier() // Mute disables the notifications. diff --git a/orbit.go b/orbit.go index 8cd8a11..b6dc885 100644 --- a/orbit.go +++ b/orbit.go @@ -15,10 +15,21 @@ import ( "github.com/gulien/orbit/commands" "github.com/gulien/orbit/notifier" + OrbitVersion "github.com/gulien/orbit/version" ) +/* +version will be set by GoReleaser. + +It will be the current Git tag (with v prefix stripped) or +the name of the snapshot if you're using the --snapshot flag. +*/ +var version = "master" + // main is the root function of the application. func main() { + OrbitVersion.Current = version + if err := commands.RootCmd.Execute(); err != nil { notifier.Error(err) os.Exit(1) diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..afe8b41 --- /dev/null +++ b/version/version.go @@ -0,0 +1,8 @@ +/* +Package version is used as a dead simple bridge between main +and command packages. +*/ +package version + +// Current is the current version of Orbit. +var Current string