Skip to content

Commit

Permalink
feat: added built at to version command
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline committed Aug 26, 2024
1 parent 87d560e commit 2a3a473
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func NewVersionCommand() *cobra.Command {
Use: "version",
Short: "Displays the build version of the CLI",
Run: func(_ *cobra.Command, _ []string) {
fmt.Printf("Version: %s\nSha: %s\n", utils.Version, utils.Sha)
fmt.Printf("Version: %s\nSha: %s\nBuilt at: %s\n", utils.Version, utils.Sha, utils.Datetime)
},
}
}
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ build:
echo "Building for local arch"
export VERSION="${RELEASE_TAG_VERSION:-dev}"
export DATETIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

go build \
-ldflags="-s -w" \
-ldflags="-X 'github.com/open-sauced/pizza-cli/pkg/utils.Version=${VERSION}'" \
-ldflags="-X 'github.com/open-sauced/pizza-cli/pkg/utils.Sha=$(git rev-parse HEAD)'" \
-ldflags="-X 'github.com/open-sauced/pizza-cli/pkg/utils.Sha=$(git rev-parse HEAD)'" \
-ldflags="-X 'github.com/open-sauced/pizza-cli/pkg/utils.Datetime=${DATETIME}'" \
-o build/pizza

install: build
Expand Down
5 changes: 3 additions & 2 deletions pkg/utils/version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package utils

var (
Version = "dev"
Sha = "HEAD"
Version = "dev"
Sha = "HEAD"
Datetime = "dev"
)

0 comments on commit 2a3a473

Please sign in to comment.