build: always inject latest git tag as version (Makefile, build.sh)

This commit is contained in:
krishnassh committed 2025-07-16 14:01:37 +05:30
1 parent 32f6d00dc2
commit 949a525f92
2 files changed
+12 -3

No files matched your search

+8 -3
View File
@@ -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
+4
View File
@@ -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