use tag info in version
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
stryan 2021-10-27 12:06:54 -04:00
parent 6f22f580dd
commit 2eff2a3559
2 changed files with 9 additions and 3 deletions

View File

@ -2,12 +2,13 @@ GOFILES=$(wildcard *.go)
PROG=simpbot PROG=simpbot
#set variables #set variables
GIT_COMMIT := $(shell git rev-list -1 HEAD) GIT_COMMIT := $(shell git rev-list -1 HEAD)
GIT_TAG := $(shell git describe --tags | cut -d- -f1)
ifeq ($(PREFIX),) # PREFIX is environment variable, but if it is not set, then set default value ifeq ($(PREFIX),) # PREFIX is environment variable, but if it is not set, then set default value
PREFIX := /usr/local PREFIX := /usr/local
endif endif
$(PROG): $(GOFILES) $(PROG): $(GOFILES)
go build -ldflags "-X main.GitCommit=$(GIT_COMMIT)" go build -ldflags "-X main.GitCommit=$(GIT_COMMIT) -X main.GitTag=$(GIT_TAG)"
clean: clean:
rm -f simpbot rm -f simpbot

View File

@ -22,6 +22,7 @@ var Password string
var DimensionServer string var DimensionServer string
var HomeserverDomain string var HomeserverDomain string
var GitCommit string var GitCommit string
var GitTag string
var Statefile string var Statefile string
var CurrStreamCnt int var CurrStreamCnt int
var MostStreamCnt int var MostStreamCnt int
@ -100,11 +101,15 @@ func main() {
vlist = append(vlist, fmt.Sprintf("%v Total:%v", vt.Name, vt.TotalStreams)) vlist = append(vlist, fmt.Sprintf("%v Total:%v", vt.Name, vt.TotalStreams))
t = t + vt.TotalStreams t = t + vt.TotalStreams
} }
statmsg = fmt.Sprintf("Current Stats Since %v:\n%v\nTotal Streams: %v\nMost Concurrent: %v/%v\n", StartTime, strings.Join(vlist, "\n"), t, MostStreamCnt, len(vtubers)) statmsg = fmt.Sprintf("Current Stats Since %v:\n%v\n\nTotal Streams: %v\nMost Concurrent: %v/%v\n", StartTime, strings.Join(vlist, "\n"), t, MostStreamCnt, len(vtubers))
client.SendText(evt.RoomID, statmsg) client.SendText(evt.RoomID, statmsg)
case "version": case "version":
// print version // print version
if GitTag != "" {
client.SendText(evt.RoomID, "SimpBot version "+GitTag)
} else {
client.SendText(evt.RoomID, "SimpBot version "+GitCommit) client.SendText(evt.RoomID, "SimpBot version "+GitCommit)
}
case "reload": case "reload":
//reload config //reload config
client.SendText(evt.RoomID, "Reloading config") client.SendText(evt.RoomID, "Reloading config")