Skip to content

Commit a5485c5

Browse files
Mixficsolwuxianrong
andauthored
fix: Fixed versions of Pika, Pika_exporter, Codis (#3057)
* Fixed versions of Pika, Pika_exporter, Codis * fix Makefile * fill code --------- Co-authored-by: wuxianrong <[email protected]>
1 parent 61a9b5a commit a5485c5

File tree

10 files changed

+50
-26
lines changed

10 files changed

+50
-26
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ endif()
736736
aux_source_directory(src DIR_SRCS)
737737

738738
# # generate version
739-
string(TIMESTAMP TS "%Y-%m-%d %H:%M:%S" UTC)
739+
string(TIMESTAMP TS "%Y-%m-%d %H:%M:%S")
740740
set(PIKA_BUILD_DATE "${TS}")
741741

742742
find_package(Git)

codis/Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
export GO111MODULE=on
44

5-
build-all: codis-dashboard codis-proxy codis-admin codis-ha codis-fe generate-version
5+
build-all: generate-version codis-dashboard codis-proxy codis-admin codis-ha codis-fe
66

77
PRJ_ROOT=${CURDIR}
88

9+
generate-version:
10+
$(info generate version)
11+
@mkdir -p ./bin && ./version
912

1013
codis-deps:
11-
@mkdir -p ./bin && go version
14+
@go version
1215
codis-dashboard: codis-deps
1316
$(info build codis-dashboard)
1417
@cd ${PRJ_ROOT}/cmd/dashboard && go mod tidy && go build -buildvcs=false -o ${PRJ_ROOT}/bin/codis-dashboard .
@@ -32,10 +35,6 @@ codis-fe: codis-deps
3235
@cd ${PRJ_ROOT}/cmd/fe && go mod tidy && go build -buildvcs=false -o ${PRJ_ROOT}/bin/codis-fe .
3336
@rm -rf ${PRJ_ROOT}/bin/assets && cp -rf ${PRJ_ROOT}/cmd/fe/assets ./bin/
3437

35-
generate-version:
36-
$(info generate version)
37-
@./version
38-
3938
clean:
4039
$(info ...Clean Start!)
4140
@rm -rf bin

codis/cmd/dashboard/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ Options:
4848
return
4949

5050
case d["--version"].(bool):
51-
fmt.Println("version:", utils.Version)
52-
fmt.Println("compile:", utils.Compile)
51+
fmt.Printf("-----------Codis Dashboard----------\n")
52+
fmt.Println("codis_version:", utils.Version)
53+
fmt.Println("codis_git_sha:", utils.Gitsha)
54+
fmt.Println("codis_build_compile_date:", utils.Compile)
55+
fmt.Println("go version:", utils.GoVersion)
5356
return
5457

5558
}

codis/cmd/fe/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ Options:
7272
}
7373

7474
if d["--version"].(bool) {
75-
fmt.Println("version:", utils.Version)
76-
fmt.Println("compile:", utils.Compile)
75+
fmt.Printf("-----------Codis FE----------\n")
76+
fmt.Println("codis_version:", utils.Version)
77+
fmt.Println("codis_git_sha:", utils.Gitsha)
78+
fmt.Println("codis_build_compile_date:", utils.Compile)
79+
fmt.Println("go version:", utils.GoVersion)
7780
return
7881
}
7982

codis/cmd/ha/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ Options:
3333
}
3434

3535
if d["--version"].(bool) {
36-
fmt.Println("version:", utils.Version)
37-
fmt.Println("compile:", utils.Compile)
36+
fmt.Printf("-----------Codis HA----------\n")
37+
fmt.Println("codis_version:", utils.Version)
38+
fmt.Println("codis_git_sha:", utils.Gitsha)
39+
fmt.Println("codis_build_compile_date:", utils.Compile)
40+
fmt.Println("go version:", utils.GoVersion)
3841
return
3942
}
4043

codis/cmd/proxy/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ Options:
5555
return
5656

5757
case d["--version"].(bool):
58-
fmt.Println("version:", utils.Version)
59-
fmt.Println("compile:", utils.Compile)
58+
fmt.Printf("-----------Codis Proxy----------\n")
59+
fmt.Println("codis_version:", utils.Version)
60+
fmt.Println("codis_git_sha:", utils.Gitsha)
61+
fmt.Println("codis_build_compile_date:", utils.Compile)
62+
fmt.Println("go version:", utils.GoVersion)
6063
return
6164

6265
}

codis/pkg/utils/version.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package utils
22

33
const (
4-
Version = "2018-11-04 16:22:35 +0800 @de1ad026e329561c22e2a3035fbfe89dc7fef764 @3.2.2-12-gde1ad026"
5-
Compile = "2023-02-23 11:25:09 +0800 by go version go1.19.6 linux/amd64"
4+
Version = "3.5.4"
5+
Gitsha = "61a9b5a6737759459a50684b8c018338ebe5808e"
6+
Compile = "2025-03-21 17:26:57 CST"
7+
GoVersion = "go1.23.4 darwin/amd64"
68
)

codis/version

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
#!/bin/bash
22

3-
version=`git log --date=iso --pretty=format:"%cd @%H" -1`
3+
CODIS_MAJOR=3
4+
CODIS_MINOR=5
5+
CODIS_PATCH=4
6+
7+
gitsha=`git log --pretty=format:"%H" -1`
48
if [ $? -ne 0 ]; then
5-
version="unknown version"
9+
gitsha="unknown git log"
610
fi
711

8-
compile=`date +"%F %T %z"`" by "`go version`
12+
compile=`date +"%F %T %Z"`
913
if [ $? -ne 0 ]; then
1014
compile="unknown datetime"
1115
fi
1216

13-
describe=`git describe --tags 2>/dev/null`
14-
if [ $? -eq 0 ]; then
15-
version="${version} @${describe}"
17+
goversion=$(go version | sed 's/go version //')
18+
if [ $? -ne 0 ]; then
19+
compile="unknown go version"
1620
fi
1721

1822
cat << EOF | gofmt > pkg/utils/version.go
1923
package utils
2024
2125
const (
22-
Version = "$version"
26+
Version = "$CODIS_MAJOR.$CODIS_MINOR.$CODIS_PATCH"
27+
Gitsha = "$gitsha"
2328
Compile = "$compile"
29+
GoVersion = "$goversion"
2430
)
2531
EOF
2632

2733
cat << EOF > bin/version
28-
version = $version
34+
gitsha = $gitsha
2935
compile = $compile
3036
EOF

tools/pika_exporter/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
# endif
44

55
# export PATH := $(PATH):$(GOPATH)/bin
6-
6+
BRANCH := $(shell git branch | sed -n 's/* \(.*\)/\1/p')
77
GITREV := $(shell git rev-parse HEAD)
88
BUILDTIME := $(shell date '+%F %T %Z')
99
COMPILERVERSION := $(subst go version ,,$(shell go version))
1010
PROJNAME := pika_exporter
11+
PIKA_EXPORTER_MAJOR := 3
12+
PIKA_EXPORTER_MINOR := 5
13+
PIKA_EXPORTER_PATCH := 5
1114

1215
define GENERATE_VERSION_CODE
1316
cat << EOF | gofmt > version.go
1417
package main
1518

1619
const (
20+
PikaExporterVersion = "$(PIKA_EXPORTER_MAJOR).$(PIKA_EXPORTER_MINOR).$(PIKA_EXPORTER_PATCH)"
1721
BuildVersion = "$(BRANCH)"
1822
BuildCommitSha = "$(GITREV)"
1923
BuildDate = "$(BUILDTIME)"

tools/pika_exporter/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func main() {
5656
flag.Parse()
5757

5858
log.Println("Pika Metrics Exporter")
59+
log.Println("Pika Exporter Version: ", PikaExporterVersion)
5960
log.Println("Build Date: ", BuildDate)
6061
log.Println("Commit SHA: ", BuildCommitSha)
6162
log.Println("Go Version: ", GoVersion)

0 commit comments

Comments
 (0)