提交 c20085a8 编写于 作者: LinuxSuRen's avatar LinuxSuRen

Add support to print version of app

上级 6afad2e1
......@@ -2,7 +2,9 @@ NAME := jcli
CGO_ENABLED = 0
GO := go
BUILD_TARGET = build
BUILDFLAGS =
COMMIT := $(shell git rev-parse --short HEAD)
VERSION := dev-$(shell git describe --tags $(shell git rev-list --tags --max-count=1))
BUILDFLAGS = -ldflags "-X github.com/linuxsuren/jenkins-cli/app.version=$(VERSION) -X github.com/linuxsuren/jenkins-cli/app.commit=$(COMMIT)"
COVERED_MAIN_SRC_FILE=./main
darwin: ## Build for OSX
......
......@@ -30,9 +30,8 @@ var rootCmd = &cobra.Command{
}
if rootOptions.Version {
fmt.Printf("Version: v%.2f.%d%s", app.CurrentVersion.Number,
app.CurrentVersion.PatchLevel,
app.CurrentVersion.Suffix)
fmt.Printf("Version: %s\n", app.GetVersion())
fmt.Printf("Commit: %s\n", app.GetCommit())
}
},
}
......
package app
// Version represents the Jenkins CLI build version.
type Version struct {
// Major and minor version.
Number float32
var (
version string
commit string
)
// Increment this for bug releases
PatchLevel int
func GetVersion() string {
return version
}
// JCLI Suffix is the suffix used in the Jenkins CLI version string.
// It will be blank for release versions.
Suffix string
func GetCommit() string {
return commit
}
package app
// CurrentVersion represents the current build version.
// This should be the only one.
var CurrentVersion = Version{
Number: 0.0,
PatchLevel: 9,
Suffix: "-DEV",
}
......@@ -15,7 +15,7 @@ echo "Updating $VERSION to $NEW_TAG"
# NEEDS_TAG=`git describe --contains $GIT_COMMIT`
if [[ -z "${NEEDS_TAG}" ]]; then
make release
make release VERSION=${NEW_TAG}
hub release create -c -a release/jcli-darwin-amd64.tar.gz \
-a release/jcli-linux-amd64.tar.gz \
-a release/jcli-windows-386.tar.gz ${NEW_TAG}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册