File tree 3 files changed +15
-1
lines changed
3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
1
builds :
2
2
- ldflags :
3
+ - -X github.com/elastic/elastic-package/internal/version.Tag={{.Tag}}
3
4
- -X github.com/elastic/elastic-package/internal/version.CommitHash={{.ShortCommit}}
4
5
- -X github.com/elastic/elastic-package/internal/version.BuildTime={{.Timestamp}}
Original file line number Diff line number Diff line change 5
5
package cmd
6
6
7
7
import (
8
+ "fmt"
9
+ "strings"
10
+
8
11
"github.com/spf13/cobra"
9
12
10
13
"github.com/elastic/elastic-package/internal/cobraext"
@@ -25,6 +28,13 @@ func setupVersionCommand() *cobraext.Command {
25
28
}
26
29
27
30
func 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 ())
29
39
return nil
30
40
}
Original file line number Diff line number Diff line change 15
15
16
16
// CommitHash is the Git hash of the branch, used for version purposes (set externally with ldflags).
17
17
CommitHash = "undefined"
18
+
19
+ // Tag describes the semver version of the application (set externally with ldflags).
20
+ Tag string
18
21
)
19
22
20
23
// BuildTimeFormatted method returns the build time preserving the RFC3339 format.
You can’t perform that action at this time.
0 commit comments