Skip to content

Commit

Permalink
Embed git tags as Version into go binary, remove the channnel field f…
Browse files Browse the repository at this point in the history
…or Slack (#238)
  • Loading branch information
haoel authored Oct 24, 2022
1 parent 92775df commit 8a29940
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ builds:
- arm64
ldflags:
- -s -w
- -X github.com/megaease/easeprobe/global.Ver={{ .Tag }}
- -X github.com/megaease/easeprobe/pkg/version.RELEASE={{ .Tag }}
- -X github.com/megaease/easeprobe/pkg/version.COMMIT={{.Commit}}
- -X github.com/megaease/easeprobe/pkg/version.REPO=megaease/easeprobe
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ MKFILE_DIR := $(dir $(MKFILE_PATH))
RELEASE_DIR := ${MKFILE_DIR}/build/bin

# Version
RELEASE?=v0.1.0
RELEASE_VER := $(shell git describe --tag --abbrev=0)

# Go MOD
GO_MOD := $(shell go list -m)

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

build: all

Expand Down
11 changes: 7 additions & 4 deletions global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ const (
Org = "MegaEase"
// DefaultProg is the program name
DefaultProg = "EaseProbe"
// DefaultIconURL is the default icon which used in Slack or Discord
DefaultIconURL = "https://megaease.com/favicon.png"
)

var (
// Ver is the program version
// It will be set by the build script
// go build -ldflags "-X github.com/megaease/easegress/pkg/global.Ver=1.0.0"
Ver = "v1.7.0"

//OrgProg combine organization and program
OrgProg = Org + " " + DefaultProg
//OrgProgVer combine organization and program and version
OrgProgVer = Org + " " + DefaultProg + "/" + Ver

// DefaultIconURL is the default icon which used in Slack or Discord
DefaultIconURL = "https://megaease.com/favicon.png"
)

const (
Expand Down
1 change: 0 additions & 1 deletion report/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func ToSlack(r probe.Result) string {

json := `
{
"channel": "Alert",
"text": "%s",
"blocks": [
{
Expand Down
1 change: 0 additions & 1 deletion report/sla.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ func SLASlackSection(r *probe.Result) string {
func SLASlack(probers []probe.Prober) string {
summary := SLASummary(probers)
json := `{
"channel": "Report",
"text": "Overall SLA Report - ` + summary + ` ",
"blocks": [
{
Expand Down

0 comments on commit 8a29940

Please sign in to comment.