Feat: Makefile + add proper git tag versioning

This commit is contained in:
kayos@tcp.direct 2023-02-28 17:18:07 -08:00
parent 3dd9ee07e1
commit 21063fff45
No known key found for this signature in database
GPG Key ID: 4B841471B4BEE979
5 changed files with 25 additions and 5 deletions

11
Makefile Normal file
View File

@ -0,0 +1,11 @@
all: deps check build
format:
find . -iname "*.go" -exec gofmt -s -l -w {} \;
check:
go vet ./...
run:
go run cmd/HellPot/*.go
deps:
go mod tidy -v
build:
go build -trimpath -ldflags "-s -w -X main.version=`git tag --sort=-version:refname | head -n 1`" cmd/HellPot/*.go

View File

@ -18,17 +18,17 @@ HellPot will send an infinite stream of data that is *just close enough* to bein
Under the hood of this eternal suffering is a markov engine that chucks bits and pieces of [The Birth of Tragedy (Hellenism and Pessimism)](https://www.gutenberg.org/files/51356/51356-h/51356-h.htm) by Friedrich Nietzsche at the client using [fasthttp](https://github.com/valyala/fasthttp). Under the hood of this eternal suffering is a markov engine that chucks bits and pieces of [The Birth of Tragedy (Hellenism and Pessimism)](https://www.gutenberg.org/files/51356/51356-h/51356-h.htm) by Friedrich Nietzsche at the client using [fasthttp](https://github.com/valyala/fasthttp).
## Compilation ## Building From Source
HellPot should probably be built with Go version 1.17 or higher. HellPot should probably be built with Go version 1.17 or higher.
HellPot uses [go modules](https://go.dev/blog/using-go-modules). This should make it dead simple to build with a stock Go installation. HellPot uses [go modules](https://go.dev/blog/using-go-modules). This should make it dead simple to build with a stock Go installation. To make it even simpler, we've added a GNU Makefile.
1 ) `git clone https://github.com/yunginnanet/HellPot` 1 ) `git clone https://github.com/yunginnanet/HellPot`
2 ) `cd HellPot` 2 ) `cd HellPot`
4 ) `go build cmd/HellPot/HellPot.go` 4 ) `make`
5 ) *Consider the potential grave consequences of your actions.* 5 ) *Consider the potential grave consequences of your actions.*

View File

@ -12,9 +12,16 @@ import (
"github.com/yunginnanet/HellPot/internal/http" "github.com/yunginnanet/HellPot/internal/http"
) )
var log zerolog.Logger var (
log zerolog.Logger
version string // set by linker
)
func init() { func init() {
if version != "" {
println(version)
config.Version = version[1:]
}
config.Init() config.Init()
if config.BannerOnly { if config.BannerOnly {
extra.Banner() extra.Banner()

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,9 @@ const Title = "HellPot"
var Version = "dev" var Version = "dev"
func init() { func init() {
if Version != "dev" {
return
}
binInfo := make(map[string]string) binInfo := make(map[string]string)
info, ok := debug.ReadBuildInfo() info, ok := debug.ReadBuildInfo()
if !ok { if !ok {