Commit 89958930 authored by suyanlong's avatar suyanlong Committed by 33cn

fix: Fixed version control

parent 6ebfb426
...@@ -39,6 +39,7 @@ jobs: ...@@ -39,6 +39,7 @@ jobs:
with: with:
branch: master branch: master
extra_plugins: | extra_plugins: |
@google/semantic-release-replace-plugin
@semantic-release/exec @semantic-release/exec
@semantic-release/changelog @semantic-release/changelog
@semantic-release/git @semantic-release/git
......
...@@ -29,6 +29,7 @@ jobs: ...@@ -29,6 +29,7 @@ jobs:
with: with:
branch: master branch: master
extra_plugins: | extra_plugins: |
@google/semantic-release-replace-plugin
@semantic-release/exec @semantic-release/exec
@semantic-release/changelog @semantic-release/changelog
@semantic-release/git @semantic-release/git
......
{ "branches": ["master", "next"], { "branches": ["master", "next"],
"plugins": [ "plugins": [
"@semantic-release/commit-analyzer", #Default 1 "@semantic-release/commit-analyzer", #Default 1
"@semantic-release/release-notes-generator", #Default 2 "@semantic-release/release-notes-generator", #Default 2
[ [
"@semantic-release/changelog", "@google/semantic-release-replace-plugin",
{ "changelogFile": "CHANGELOG.md", "changelogTitle": "changelog" }, {
], "replacements": [
# "@semantic-release/npm", #Default 3 {
# "@semantic-release/github", #Default 4 "files": ["version/version.go"],
[ "from": 'Version =.*',
"@semantic-release/github", "to": 'Version = "${nextRelease.version}"',
{"assets": ["build/*.tar.gz","build/*.zip"]} "results": [
], {
"file": "version/version.go",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
},
{
{
"files": [ "README.md" ],
"from": "# chain33 官方插件系统(.*)",
"to": "# chain33 官方插件系统(v${nextRelease.version})",
"results": [
{
"file": "README.md",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
},
}
]
}
],
[
"@semantic-release/changelog",
{ "changelogFile": "CHANGELOG.md", "changelogTitle": "changelog" },
],
# "@semantic-release/npm", #Default 3
# "@semantic-release/github", #Default 4
[
"@semantic-release/github",
{"assets": ["build/*.tar.gz","build/*.zip"]}
],
[
"@semantic-release/git", "@semantic-release/git",
[ {
"@semantic-release/exec", { "assets": ["version/version.go","CHANGELOG.md","README.md"],
"prepareCmd": "make all-arch" }
} ],
] [
"@semantic-release/exec", {
"prepareCmd": "make all-arch VERSION=${nextRelease.version}"
}
]
] ]
} }
...@@ -8,8 +8,14 @@ export GO111MODULE=on ...@@ -8,8 +8,14 @@ export GO111MODULE=on
CLI := build/chain33-cli CLI := build/chain33-cli
SRC_CLI := github.com/33cn/plugin/cli SRC_CLI := github.com/33cn/plugin/cli
APP := build/chain33 APP := build/chain33
BUILD_FLAGS = -ldflags "-X github.com/33cn/chain33/common/version.GitCommit=`git rev-parse --short=8 HEAD`" LDFLAGS := ' -w -s'
LDFLAGS := -ldflags "-w -s" BUILDTIME:=$(shell date +"%Y-%m-%d %H:%M:%S %A")
VERSION=$(shell git describe --tags || git rev-parse --short=8 HEAD)
GitCommit=$(shell git rev-parse --short=8 HEAD)
BUILD_FLAGS := -ldflags '-X "github.com/33cn/plugin/version.GitCommit=$(GitCommit)" \
-X "github.com/33cn/plugin/version.Version=$(VERSION)" \
-X "github.com/33cn/plugin/version.BuildTime=$(BUILDTIME)"'
MKPATH=$(abspath $(lastword $(MAKEFILE_LIST))) MKPATH=$(abspath $(lastword $(MAKEFILE_LIST)))
MKDIR=$(dir $(MKPATH)) MKDIR=$(dir $(MKPATH))
proj := "build" proj := "build"
......
...@@ -12,11 +12,27 @@ ...@@ -12,11 +12,27 @@
package main package main
import ( import (
"flag"
"fmt"
frameVersion "github.com/33cn/chain33/common/version"
_ "github.com/33cn/chain33/system" _ "github.com/33cn/chain33/system"
"github.com/33cn/chain33/util/cli" "github.com/33cn/chain33/util/cli"
_ "github.com/33cn/plugin/plugin" _ "github.com/33cn/plugin/plugin"
"github.com/33cn/plugin/version"
)
var (
versionCmd = flag.Bool("version", false, "detail version")
) )
func main() { func main() {
flag.Parse()
if *versionCmd {
fmt.Println(fmt.Sprintf("build time: %s", version.BuildTime))
fmt.Println(fmt.Sprintf("plugin version: %s", version.GetVersion()))
fmt.Println(fmt.Sprintf("chain33 frame version: %s", frameVersion.GetVersion()))
return
}
cli.RunChain33("", "") cli.RunChain33("", "")
} }
package version
//var version control
var (
Version = "master"
GitCommit string
BuildTime string
)
//GetVersion 获取版本信息
func GetVersion() string {
if GitCommit != "" {
return Version + "-" + GitCommit
}
return Version
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment