diff --git a/Makefile b/Makefile index a693ee3..e2ae64c 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ -.PHONY: install +.PHONY: install build + +VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev") # Install GopherTube (build, install binary, install man page, create config) install: go mod tidy - go build -o gophertube main.go + go build -ldflags "-X main.version=$(VERSION)" -o gophertube main.go sudo cp gophertube /usr/local/bin/ sudo mkdir -p /usr/local/share/man/man1 sudo cp man/gophertube.1 /usr/local/share/man/man1/ @@ -12,6 +14,9 @@ install: cp config/gophertube.yaml.example ~/.config/gophertube/gophertube.yaml @echo "GopherTube installed successfully!" @echo "Configuration file created at ~/.config/gophertube/gophertube.yaml" - @echo "Run 'gophertube --help' to get started." + @echo "Run 'gophertube --help' to get started." + +build: + go build -ldflags "-X main.version=$(VERSION)" -o gophertube main.go \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..534663c --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +#!/bin/sh +LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "dev") +echo "Building GopherTube with version: $LATEST_TAG" +go build -ldflags "-X main.version=$LATEST_TAG" -o gophertube main.go \ No newline at end of file