Skip to content

Commit

Permalink
Read version from ldflags
Browse files Browse the repository at this point in the history
  • Loading branch information
viveksinghggits committed Mar 6, 2022
1 parent 974a059 commit 4c58f97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ builds:
- linux
- windows
- darwin
ldflags:
- -s -w
-X github.com/viveksinghggits/akcess/cmd.VERSION={{.Version}}
archives:
- replacements:
darwin: Darwin
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ var (
options = &utils.AllowOptions{}
res = []string{}
delIdentifier string
// VERSION will be overriden by ldflags when we build the project using goreleaser
VERSION = "DEV"
)

func init() {
Expand All @@ -79,7 +81,7 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: fmt.Sprintf("Print the version of %s", utils.Name),
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("akcess 0.0.1")
fmt.Println(VERSION)
},
}

Expand Down

0 comments on commit 4c58f97

Please sign in to comment.