Skip to content

Commit

Permalink
Merge pull request #107 from commitdev/version
Browse files Browse the repository at this point in the history
version and build sha injected at link time into binary
  • Loading branch information
trevoro committed Mar 27, 2020
2 parents 959abff + 52705bc commit 8c72dc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
7 changes: 6 additions & 1 deletion Makefile
@@ -1,3 +1,8 @@
VERSION = 0.0.1
BUILD ?=$(shell git rev-parse --short HEAD)
PKG ?=github.com/commitdev/commit0
BUILD_ARGS=-v -ldflags=all="-X ${PKG}/cmd.appVersion=${VERSION} -X ${PKG}/cmd.appBuild=${BUILD}"

check:
go test ./...

Expand All @@ -13,7 +18,7 @@ build-example-docker: clean-example
docker run -v "$(shell pwd)/example/hello-world:/project" --user $(shell id -u):$(shell id -g) commit0:v0 generate -l go

build:
go build -o commit0
go build ${BUILD_ARGS}

# Installs the CLI int your GOPATH
install-go:
Expand Down
8 changes: 7 additions & 1 deletion cmd/version.go
Expand Up @@ -6,6 +6,11 @@ import (
"github.com/spf13/cobra"
)

var (
appVersion = "SNAPSHOT"
appBuild = "SNAPSHOT"
)

func init() {
rootCmd.AddCommand(versionCmd)
}
Expand All @@ -14,6 +19,7 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of commit0",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("v0.0.0") // Updated via updateVersion.sh
fmt.Printf("version: %v\n", appVersion)
fmt.Printf("build: %v\n", appBuild)
},
}
12 changes: 0 additions & 12 deletions updateVersion.sh

This file was deleted.

0 comments on commit 8c72dc9

Please sign in to comment.