From 00e0b0da54e1f46be799480c7d9e57cb748574d5 Mon Sep 17 00:00:00 2001 From: George Kontridze Date: Sun, 10 May 2020 02:20:13 -0700 Subject: [PATCH] Add versioning --- .goreleaser.yml | 8 ++++---- VERSION | 1 + cmd/awssume/awssume.go | 20 +++++++++++++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 VERSION diff --git a/.goreleaser.yml b/.goreleaser.yml index d2aa9af..99574bb 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -18,10 +18,10 @@ brews: github: name: homebrew-gkze owner: gkze - homepage: "https://github.com/gkze/roles" - test: "system \"#{bin}/role -v\"" + homepage: "https://github.com/gkze/awssume" + test: "system \"#{bin}/awssume -v\"" builds: -- binary: role +- binary: awssume env: - GO111MODULE=on - CGO_ENABLED=0 @@ -29,7 +29,7 @@ builds: - amd64 ldflags: - -X main.Version={{ .Version }} - main: "./cmd/role/role.go" + main: "./cmd/awssume/awssume.go" changelog: filters: exclude: diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..77d6f4c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.0 diff --git a/cmd/awssume/awssume.go b/cmd/awssume/awssume.go index c013e2e..019115c 100644 --- a/cmd/awssume/awssume.go +++ b/cmd/awssume/awssume.go @@ -17,8 +17,13 @@ import ( // errCurrentUser is returned when the current used cannot be determined const errCurrentUser string = "error determining current user: %w" -// errTooFewArguments is returned when there are not enough arguments passed -var errTooFewArguments error = errors.New("not enough arguments provided") +var ( + // errTooFewArguments is returned when there are not enough arguments passed + errTooFewArguments error = errors.New("not enough arguments provided") + + // Version is dynamically injected at build time + Version string +) func main() { rootCmd := cobra.Command{ @@ -33,6 +38,15 @@ func main() { }, } + versionCmd := &cobra.Command{ + Use: "version", + Short: "Display awssume version", + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Printf("awssume version %s\n", Version) + return nil + }, + } + listCmd := &cobra.Command{ Use: "list", Aliases: []string{"l", "ls"}, @@ -198,7 +212,7 @@ func main() { "The duration of the STS Session when the Role is assumed", ) - rootCmd.AddCommand(listCmd, convertCmd, addCmd, execCmd) + rootCmd.AddCommand(versionCmd, listCmd, convertCmd, addCmd, execCmd) if err := rootCmd.Execute(); err != nil { fmt.Println(err)