diff --git a/.github/labeler-config.yml b/.github/labeler-config.yml index 01a9ba683370868be259e96347420714cee63fd1..46333afffabd1eb5186ff2c46aa147df73971fdc 100644 --- a/.github/labeler-config.yml +++ b/.github/labeler-config.yml @@ -1,4 +1,4 @@ -"bug": '\b([Bb]ug(s)?|[Ee]rror(s)?|[Ff]ix(es)?|[Ii]ssue(s)?)\b' +"bug": '\b([Bb]ug(s)?|[Ee]rror(s)?|[Ff]ix(es)?)\b' "enhancement": '\b([Ee]nhancement(s)?|[Ff]eature(s)?|[Ii]dea(s)?|[Ss]uggestion(s)?[Ff]eat(s)?)\b' diff --git a/Makefile b/Makefile index 2682d811c3c7440d2f6736ac56e9fd0c339108b6..39addab0e2ac487f862434e6428d2b6c3c5f5b19 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build test run clean lint fmt vet +.PHONY: build test run clean lint fmt vet build-full BINARY_NAME=matcha BUILD_DIR=bin @@ -11,6 +11,16 @@ generate_gif: build: go build -o $(BUILD_DIR)/$(BINARY_NAME) . +build-full: + @echo "Building with version information..." + @VERSION=$$(git describe --tags --abbrev=0 2>/dev/null || echo "dev"); \ + COMMIT=$$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \ + DATE=$$(date +%Y-%m-%d); \ + echo "Version: $$VERSION"; \ + echo "Commit: $$COMMIT"; \ + echo "Date: $$DATE"; \ + go build -ldflags="-X 'main.version=$$VERSION' -X 'main.commit=$$COMMIT' -X 'main.date=$$DATE'" -o $(BUILD_DIR)/$(BINARY_NAME)-full .; + run: go run . diff --git a/main.go b/main.go index ab04ba9845a7c1080fee2ffd6aa6b82811b7a8d0..41c308ee7e7df78f38416b52cf2741d357f5a689 100644 --- a/main.go +++ b/main.go @@ -1952,6 +1952,19 @@ func filterUnique(existing, incoming []fetcher.Email) []fetcher.Email { } func main() { + // If invoked with version flag, print version and exit + if len(os.Args) > 1 && (os.Args[1] == "-v" || os.Args[1] == "--version" || os.Args[1] == "version") { + fmt.Printf("matcha version %s", version) + if commit != "" { + fmt.Printf(" (%s)", commit) + } + if date != "" { + fmt.Printf(" built on %s", date) + } + fmt.Println() + os.Exit(0) + } + // If invoked as CLI update command, run updater and exit. if len(os.Args) > 1 && os.Args[1] == "update" { if err := runUpdateCLI(); err != nil {