diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e52f44c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tglistbot* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5a9ff06 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ + +VERSION = $(shell git describe --tags --abbrev=0) + +build_release: + CGO_ENABLED=0 go build -buildmode=pie -ldflags "-X main.version=$(VERSION)" -o tglistbot-$(VERSION) + +release_check: + go list -m go.balki.me/tglistbot@$(VERSION) + diff --git a/main.go b/main.go index 31b8c3c..fc5e176 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,8 @@ import ( "go.balki.me/tglistbot/glist" ) +// Version will be set from build commandline +var Version string var apiToken string func main() { @@ -61,7 +63,10 @@ func main() { glist.DataPath = dataPath - commit := func() string { + version := func() string { + if Version != "" { + return Version + } if bi, ok := debug.ReadBuildInfo(); ok { for _, s := range bi.Settings { if s.Key == "vcs.revision" { @@ -79,7 +84,7 @@ func main() { return fmt.Sprintf("port: %v", port) }() - log.Printf("List bot (%s) starting with datapath: %q, %s\n", commit, dataPath, listeningOn) + log.Printf("List bot (%s) starting with datapath: %q, %s\n", version, dataPath, listeningOn) var chats sync.Map if err := loadData(dataPath, &chats); err != nil {