diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d162e..6101a36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# For next release + * **Raphael Pour** + * cmd/root: add go version and last commit sha to the --version build information + +*Not released yet* + # Major Release v1.0.0 (2023-07-12) * **Raphael Pour** * render: diff --git a/cmd/root.go b/cmd/root.go index 58e48dc..f257a22 100755 --- a/cmd/root.go +++ b/cmd/root.go @@ -19,6 +19,7 @@ package cmd import ( "fmt" "os" + "runtime/debug" "github.com/spf13/cobra" ) @@ -29,8 +30,18 @@ var rootCmd = &cobra.Command{ Long: "Blogctl manages blog markdown-based posts database-less and generates a static website on-demand", RunE: func(cmd *cobra.Command, args []string) error { if Version { - fmt.Println("BuildVersion: ", BuildVersion) - fmt.Println("BuildDate: ", BuildDate) + fmt.Println("BuildVersion:", BuildVersion) + fmt.Println("BuildDate:", BuildDate) + + if buildInfo, ok := debug.ReadBuildInfo(); ok { + fmt.Println("GoVersion:", buildInfo.GoVersion) + for _, pair := range buildInfo.Settings { + if pair.Key == "vcs.revision" { + fmt.Println("Commit:", pair.Value) + break + } + } + } return nil } return cmd.Help()