[add] YAO CMD PRVERSION Support
This commit is contained in:
parent
be4fc68c05
commit
33ae449cd9
3 changed files with 42 additions and 2 deletions
33
Makefile
33
Makefile
|
|
@ -1,9 +1,11 @@
|
||||||
GO ?= go
|
GO ?= go
|
||||||
|
GIT ?= git
|
||||||
GOFMT ?= gofmt "-s"
|
GOFMT ?= gofmt "-s"
|
||||||
PACKAGES ?= $(shell $(GO) list ./...)
|
PACKAGES ?= $(shell $(GO) list ./...)
|
||||||
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)
|
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)
|
||||||
GOFILES := $(shell find . -name "*.go")
|
GOFILES := $(shell find . -name "*.go")
|
||||||
VERSION := $(shell grep 'const VERSION =' share/const.go |awk '{print $$4}' |sed 's/\"//g')
|
VERSION := $(shell grep 'const VERSION =' share/const.go |awk '{print $$4}' |sed 's/\"//g')
|
||||||
|
COMMIT := $(shell git log | head -n 1 | awk '{print substr($$2, 0, 12)}')
|
||||||
|
|
||||||
# ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
# ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
TESTFOLDER := $(shell $(GO) list ./... | grep -vE 'examples|tests*|config')
|
TESTFOLDER := $(shell $(GO) list ./... | grep -vE 'examples|tests*|config')
|
||||||
|
|
@ -131,6 +133,9 @@ artifacts-linux: clean
|
||||||
rm -rf .tmp/data
|
rm -rf .tmp/data
|
||||||
rm -rf .tmp/ui
|
rm -rf .tmp/ui
|
||||||
|
|
||||||
|
# Replace PRVERSION
|
||||||
|
sed -ie "s/const PRVERSION = \"DEV\"/const PRVERSION = \"${COMMIT}\"/g" share/const.go
|
||||||
|
|
||||||
# Making artifacts
|
# Making artifacts
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
CGO_ENABLED=1 CGO_LDFLAGS="-static" GOOS=linux GOARCH=amd64 go build -v -o dist/yao-${VERSION}-linux-amd64
|
CGO_ENABLED=1 CGO_LDFLAGS="-static" GOOS=linux GOARCH=amd64 go build -v -o dist/yao-${VERSION}-linux-amd64
|
||||||
|
|
@ -142,6 +147,10 @@ artifacts-linux: clean
|
||||||
ls -l dist/release/
|
ls -l dist/release/
|
||||||
dist/release/yao-${VERSION}-linux-amd64 version
|
dist/release/yao-${VERSION}-linux-amd64 version
|
||||||
|
|
||||||
|
# Reset const
|
||||||
|
# cp -f share/const.goe share/const.go
|
||||||
|
# rm -f share/const.goe
|
||||||
|
|
||||||
# make artifacts-macos
|
# make artifacts-macos
|
||||||
.PHONY: artifacts-macos
|
.PHONY: artifacts-macos
|
||||||
artifacts-macos: clean
|
artifacts-macos: clean
|
||||||
|
|
@ -159,6 +168,9 @@ artifacts-macos: clean
|
||||||
rm -rf .tmp/data
|
rm -rf .tmp/data
|
||||||
rm -rf .tmp/ui
|
rm -rf .tmp/ui
|
||||||
|
|
||||||
|
# Replace PRVERSION
|
||||||
|
sed -ie "s/const PRVERSION = \"DEV\"/const PRVERSION = \"${COMMIT}\"/g" share/const.go
|
||||||
|
|
||||||
# Making artifacts
|
# Making artifacts
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -v -o dist/yao-${VERSION}-darwin-amd64
|
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -v -o dist/yao-${VERSION}-darwin-amd64
|
||||||
|
|
@ -170,6 +182,10 @@ artifacts-macos: clean
|
||||||
ls -l dist/release/
|
ls -l dist/release/
|
||||||
dist/release/yao-${VERSION}-darwin-amd64 version
|
dist/release/yao-${VERSION}-darwin-amd64 version
|
||||||
|
|
||||||
|
# Reset const
|
||||||
|
# cp -f share/const.goe share/const.go
|
||||||
|
# rm -f share/const.goe
|
||||||
|
|
||||||
.PHONY: debug
|
.PHONY: debug
|
||||||
debug: clean
|
debug: clean
|
||||||
mkdir -p dist/release
|
mkdir -p dist/release
|
||||||
|
|
@ -181,11 +197,19 @@ debug: clean
|
||||||
go-bindata -fs -pkg data -o data/bindata.go -prefix ".tmp/data/" .tmp/data/...
|
go-bindata -fs -pkg data -o data/bindata.go -prefix ".tmp/data/" .tmp/data/...
|
||||||
rm -rf .tmp/data
|
rm -rf .tmp/data
|
||||||
|
|
||||||
|
|
||||||
|
# Replace PRVERSION
|
||||||
|
sed -ie "s/const PRVERSION = \"DEV\"/const PRVERSION = \"${COMMIT}-debug\"/g" share/const.go
|
||||||
|
|
||||||
# Making artifacts
|
# Making artifacts
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
CGO_ENABLED=1 go build -v -o dist/release/yao-debug
|
CGO_ENABLED=1 go build -v -o dist/release/yao-debug
|
||||||
chmod +x dist/release/yao-debug
|
chmod +x dist/release/yao-debug
|
||||||
|
|
||||||
|
# Reset const
|
||||||
|
cp -f share/const.goe share/const.go
|
||||||
|
rm -f share/const.goe
|
||||||
|
|
||||||
.PHONY: release
|
.PHONY: release
|
||||||
release: clean
|
release: clean
|
||||||
mkdir -p dist/release
|
mkdir -p dist/release
|
||||||
|
|
@ -194,7 +218,7 @@ release: clean
|
||||||
# Building UI
|
# Building UI
|
||||||
git clone https://github.com/YaoApp/xgen.git .tmp/ui
|
git clone https://github.com/YaoApp/xgen.git .tmp/ui
|
||||||
sed -ie "s/url('\/icon/url('\/xiang\/icon/g" .tmp/ui/public/icon/md_icon.css
|
sed -ie "s/url('\/icon/url('\/xiang\/icon/g" .tmp/ui/public/icon/md_icon.css
|
||||||
cd .tmp/ui && yarn install && yarn build
|
cd .tmp/ui && cnpm install && npm run build
|
||||||
|
|
||||||
# Packing
|
# Packing
|
||||||
mkdir -p .tmp/data
|
mkdir -p .tmp/data
|
||||||
|
|
@ -204,11 +228,18 @@ release: clean
|
||||||
rm -rf .tmp/data
|
rm -rf .tmp/data
|
||||||
rm -rf .tmp/ui
|
rm -rf .tmp/ui
|
||||||
|
|
||||||
|
# Replace PRVERSION
|
||||||
|
sed -ie "s/const PRVERSION = \"DEV\"/const PRVERSION = \"${COMMIT}\"/g" share/const.go
|
||||||
|
|
||||||
# Making artifacts
|
# Making artifacts
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
CGO_ENABLED=1 go build -v -o dist/release/yao
|
CGO_ENABLED=1 go build -v -o dist/release/yao
|
||||||
chmod +x dist/release/yao
|
chmod +x dist/release/yao
|
||||||
|
|
||||||
|
# Reset const
|
||||||
|
cp -f share/const.goe share/const.go
|
||||||
|
rm share/const.goe
|
||||||
|
|
||||||
.PHONY: linux-release
|
.PHONY: linux-release
|
||||||
linux-release: clean
|
linux-release: clean
|
||||||
mkdir -p dist/release
|
mkdir -p dist/release
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,13 @@ var versionCmd = &cobra.Command{
|
||||||
Short: L("Show version"),
|
Short: L("Show version"),
|
||||||
Long: L("Show version"),
|
Long: L("Show version"),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
|
version := share.VERSION
|
||||||
|
if share.PRVERSION != "" {
|
||||||
|
version = fmt.Sprintf("%s-%s", share.VERSION, share.PRVERSION)
|
||||||
|
}
|
||||||
|
|
||||||
// Do Stuff Here
|
// Do Stuff Here
|
||||||
fmt.Println(share.VERSION)
|
fmt.Println(version)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@ package share
|
||||||
// VERSION 版本号
|
// VERSION 版本号
|
||||||
const VERSION = "0.9.2"
|
const VERSION = "0.9.2"
|
||||||
|
|
||||||
|
// PRVERSION PreRelease Version
|
||||||
|
const PRVERSION = "DEV"
|
||||||
|
|
||||||
// BUILDIN 打包应用合成一个制品
|
// BUILDIN 打包应用合成一个制品
|
||||||
const BUILDIN = false
|
const BUILDIN = false
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue