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

fix: Fixed version control

parent 6ebfb426
......@@ -39,6 +39,7 @@ jobs:
with:
branch: master
extra_plugins: |
@google/semantic-release-replace-plugin
@semantic-release/exec
@semantic-release/changelog
@semantic-release/git
......
......@@ -29,6 +29,7 @@ jobs:
with:
branch: master
extra_plugins: |
@google/semantic-release-replace-plugin
@semantic-release/exec
@semantic-release/changelog
@semantic-release/git
......
{ "branches": ["master", "next"],
{ "branches": ["master", "next"],
"plugins": [
"@semantic-release/commit-analyzer", #Default 1
"@semantic-release/release-notes-generator", #Default 2
[
"@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/commit-analyzer", #Default 1
"@semantic-release/release-notes-generator", #Default 2
[
"@google/semantic-release-replace-plugin",
{
"replacements": [
{
"files": ["version/version.go"],
"from": 'Version =.*',
"to": 'Version = "${nextRelease.version}"',
"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/exec", {
"prepareCmd": "make all-arch"
}
]
{
"assets": ["version/version.go","CHANGELOG.md","README.md"],
}
],
[
"@semantic-release/exec", {
"prepareCmd": "make all-arch VERSION=${nextRelease.version}"
}
]
]
}
......@@ -8,8 +8,14 @@ export GO111MODULE=on
CLI := build/chain33-cli
SRC_CLI := github.com/33cn/plugin/cli
APP := build/chain33
BUILD_FLAGS = -ldflags "-X github.com/33cn/chain33/common/version.GitCommit=`git rev-parse --short=8 HEAD`"
LDFLAGS := -ldflags "-w -s"
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)))
MKDIR=$(dir $(MKPATH))
proj := "build"
......
......@@ -12,11 +12,27 @@
package main
import (
"flag"
"fmt"
frameVersion "github.com/33cn/chain33/common/version"
_ "github.com/33cn/chain33/system"
"github.com/33cn/chain33/util/cli"
_ "github.com/33cn/plugin/plugin"
"github.com/33cn/plugin/version"
)
var (
versionCmd = flag.Bool("version", false, "detail version")
)
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("", "")
}
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