Files
unitdore/Makefile
Hein 0b34b182a9
Some checks failed
Release / test (push) Successful in -30m44s
Release / release (push) Successful in -30m36s
Release / pkg-arch (push) Failing after -30m14s
Release / pkg-deb (push) Successful in -30m4s
Release / pkg-rpm (push) Failing after -28m19s
feat(release): add packaging support for Arch, Debian, and RPM
* Implement Arch package build process in release workflow
* Add Debian and RPM packaging specifications
* Include man page installation in Makefile
* Create unitdore man page for documentation
2026-04-08 14:28:09 +02:00

60 lines
1.7 KiB
Makefile

BINARY := unitdore
INSTALL_DIR := /usr/local/bin
CONFIG_DIR := /etc/unitdore
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -ldflags "-X main.version=$(VERSION)"
.PHONY: all build install uninstall test lint clean release-version
all: build
## build: compile the binary
build:
go build $(LDFLAGS) -o $(BINARY) .
## install: install binary, man page, and create config dir
install: build
install -Dm755 $(BINARY) $(INSTALL_DIR)/$(BINARY)
install -Dm644 docs/unitdore.1 /usr/share/man/man1/unitdore.1
mkdir -p $(CONFIG_DIR)
@echo "Installed to $(INSTALL_DIR)/$(BINARY)"
@echo "Config dir: $(CONFIG_DIR)"
## uninstall: remove binary and man page
uninstall:
rm -f $(INSTALL_DIR)/$(BINARY)
rm -f /usr/share/man/man1/unitdore.1
@echo "Removed $(INSTALL_DIR)/$(BINARY)"
## test: run all unit tests
test:
go test ./... -v
## test-short: run tests without verbose output
test-short:
go test ./...
## lint: run go vet
lint:
go vet ./...
## clean: remove built binary
clean:
rm -f $(BINARY)
## release-version: bump patch version, tag, and push to trigger release workflow
release-version:
@CURRENT=$$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"); \
MAJOR=$$(echo $$CURRENT | sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'); \
MINOR=$$(echo $$CURRENT | sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'); \
PATCH=$$(echo $$CURRENT | sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'); \
NEXT="v$$MAJOR.$$MINOR.$$((PATCH + 1))"; \
echo "Current: $$CURRENT → Next: $$NEXT"; \
git tag -a "$$NEXT" -m "Release $$NEXT"; \
git push origin "$$NEXT"; \
echo "Pushed tag $$NEXT — release workflow triggered"
## help: show this help
help:
@grep -E '^## ' Makefile | sed 's/## / /'