Skip to content

Commit 8a29940

Browse files
authored
Embed git tags as Version into go binary, remove the channnel field for Slack (#238)
1 parent 92775df commit 8a29940

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

.goreleaser.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ builds:
2828
- arm64
2929
ldflags:
3030
- -s -w
31+
- -X github.com/megaease/easeprobe/global.Ver={{ .Tag }}
3132
- -X github.com/megaease/easeprobe/pkg/version.RELEASE={{ .Tag }}
3233
- -X github.com/megaease/easeprobe/pkg/version.COMMIT={{.Commit}}
3334
- -X github.com/megaease/easeprobe/pkg/version.REPO=megaease/easeprobe

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ MKFILE_DIR := $(dir $(MKFILE_PATH))
99
RELEASE_DIR := ${MKFILE_DIR}/build/bin
1010

1111
# Version
12-
RELEASE?=v0.1.0
12+
RELEASE_VER := $(shell git describe --tag --abbrev=0)
13+
14+
# Go MOD
15+
GO_MOD := $(shell go list -m)
1316

1417
# Git Related
1518
GIT_REPO_INFO=$(shell cd ${MKFILE_DIR} && git config --get remote.origin.url)
@@ -27,7 +30,7 @@ all: ${TARGET}
2730
${TARGET}: ${SOURCE}
2831
mkdir -p ${RELEASE_DIR}
2932
go mod tidy
30-
CGO_ENABLED=0 go build -a -ldflags '-s -w -extldflags "-static"' -o ${TARGET} github.com/megaease/easeprobe/cmd/easeprobe
33+
CGO_ENABLED=0 go build -a -ldflags "-s -w -extldflags -static -X ${GO_MOD}/global.Ver=${RELEASE_VER}" -o ${TARGET} ${GO_MOD}/cmd/easeprobe
3134

3235
build: all
3336

global/global.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,19 @@ const (
3737
Org = "MegaEase"
3838
// DefaultProg is the program name
3939
DefaultProg = "EaseProbe"
40+
// DefaultIconURL is the default icon which used in Slack or Discord
41+
DefaultIconURL = "https://megaease.com/favicon.png"
42+
)
43+
44+
var (
4045
// Ver is the program version
46+
// It will be set by the build script
47+
// go build -ldflags "-X github.com/megaease/easegress/pkg/global.Ver=1.0.0"
4148
Ver = "v1.7.0"
42-
4349
//OrgProg combine organization and program
4450
OrgProg = Org + " " + DefaultProg
4551
//OrgProgVer combine organization and program and version
4652
OrgProgVer = Org + " " + DefaultProg + "/" + Ver
47-
48-
// DefaultIconURL is the default icon which used in Slack or Discord
49-
DefaultIconURL = "https://megaease.com/favicon.png"
5053
)
5154

5255
const (

report/result.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ func ToSlack(r probe.Result) string {
162162

163163
json := `
164164
{
165-
"channel": "Alert",
166165
"text": "%s",
167166
"blocks": [
168167
{

report/sla.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ func SLASlackSection(r *probe.Result) string {
277277
func SLASlack(probers []probe.Prober) string {
278278
summary := SLASummary(probers)
279279
json := `{
280-
"channel": "Report",
281280
"text": "Overall SLA Report - ` + summary + ` ",
282281
"blocks": [
283282
{

0 commit comments

Comments
 (0)