Skip to content

Commit

Permalink
build: add commit & date to the version output
Browse files Browse the repository at this point in the history
  • Loading branch information
ekalinin committed Jul 21, 2020
1 parent a1d84bb commit d1eace3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ builds:
- darwin
- windows
ldflags:
- -s -w -X cmd.pbVersion={{.Version}} -X cmd.pbCommit={{.Commit}}
- -s -w -X github.com/ekalinin/pbvm/cmd.pbVersion={{.Version}} -X github.com/ekalinin/pbvm/cmd.pbCommit={{.ShortCommit}} -X github.com/ekalinin/pbvm/cmd.pbBuildDt={{.Date}}
archives:
- replacements:
386: x86_32
Expand Down
7 changes: 5 additions & 2 deletions cmd/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ const (
pbDateFormat = "2006.01.02"
)

// Version will be set by goreleaser (see .goreleaser.yml)
// pbVersion will be set by goreleaser (see .goreleaser.yml)
var pbVersion = "dev"

// Commit will be set by goreleaser (see .goreleaser.yml)
// pbCommit will be set by goreleaser (see .goreleaser.yml)
var pbCommit = "unknown"

// pbBuildDt will be set by goreleaser (see .goreleaser.yml)
var pbBuildDt = "now"
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var rootCmd = &cobra.Command{
Use: pbName,
Short: "Protocol Buffers Version Manager",
Long: `It is a CLI tool for easy install/switch any versions of the Protocol Buffers.`,
Version: pbVersion + "@" + pbCommit,
Version: pbVersion + " (commit=" + pbCommit + ", date=" + pbBuildDt + ")",
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down

0 comments on commit d1eace3

Please sign in to comment.