File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 11builds :
22 - ldflags :
3+ - -X github.com/elastic/elastic-package/internal/version.Tag={{.Tag}}
34 - -X github.com/elastic/elastic-package/internal/version.CommitHash={{.ShortCommit}}
45 - -X github.com/elastic/elastic-package/internal/version.BuildTime={{.Timestamp}}
Original file line number Diff line number Diff line change 55package cmd
66
77import (
8+ "fmt"
9+ "strings"
10+
811 "github.com/spf13/cobra"
912
1013 "github.com/elastic/elastic-package/internal/cobraext"
@@ -25,6 +28,13 @@ func setupVersionCommand() *cobraext.Command {
2528}
2629
2730func versionCommandAction (cmd * cobra.Command , args []string ) error {
28- cmd .Printf ("elastic-package version-hash %s (build time: %s)\n " , version .CommitHash , version .BuildTimeFormatted ())
31+ var sb strings.Builder
32+ sb .WriteString ("elastic-package " )
33+ if version .Tag != "" {
34+ sb .WriteString (version .Tag )
35+ sb .WriteString (" " )
36+ }
37+ sb .WriteString (fmt .Sprintf ("version-hash %s (build time: %s)" , version .CommitHash , version .BuildTimeFormatted ()))
38+ fmt .Println (sb .String ())
2939 return nil
3040}
Original file line number Diff line number Diff line change 1515
1616 // CommitHash is the Git hash of the branch, used for version purposes (set externally with ldflags).
1717 CommitHash = "undefined"
18+
19+ // Tag describes the semver version of the application (set externally with ldflags).
20+ Tag string
1821)
1922
2023// BuildTimeFormatted method returns the build time preserving the RFC3339 format.
You can’t perform that action at this time.
0 commit comments