Files
dns-updater/Makefile
T
unkinben fa6db89f0d
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
make: fix bump target version parsing
The heredoc-based read broke across make's per-line recipe handling. Parse the
current version with cut in a single backslash-continued shell instead, and
error on an unknown PART.
2026-07-17 23:30:36 +10:00

57 lines
1.3 KiB
Makefile

GO_VERSION := 1.25
BINARY := dns-updater
PKG := git.unkin.net/unkin/dns-updater
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' || echo 0.0.0)
LDFLAGS := -X main.version=$(VERSION)
.PHONY: all build test vet fmt tidy lint rpm clean patch minor major
all: build
build:
mkdir -p dist
CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o dist/$(BINARY) ./cmd/$(BINARY)
test:
go test ./...
vet:
go vet ./...
fmt:
gofmt -l -w .
tidy:
go mod tidy
lint: vet
@gofmt -l . | grep . && { echo "gofmt needed"; exit 1; } || echo "gofmt clean"
rpm: build
./scripts/build-rpm.sh $(VERSION)
clean:
rm -rf $(BINARY) dist *.rpm
# Version bump targets: tag vX.Y.Z and push so Woodpecker builds the release.
patch: ; @$(MAKE) bump PART=patch
minor: ; @$(MAKE) bump PART=minor
major: ; @$(MAKE) bump PART=major
bump:
@cur=$$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//'); \
[ -n "$$cur" ] || cur=0.0.0; \
MA=$$(echo "$$cur" | cut -d. -f1); \
MI=$$(echo "$$cur" | cut -d. -f2); \
PA=$$(echo "$$cur" | cut -d. -f3); \
case "$(PART)" in \
major) MA=$$((MA+1)); MI=0; PA=0;; \
minor) MI=$$((MI+1)); PA=0;; \
patch) PA=$$((PA+1));; \
*) echo "unknown PART=$(PART)"; exit 1;; \
esac; \
new="v$$MA.$$MI.$$PA"; \
echo "tagging $$new"; \
git tag -a "$$new" -m "release $$new"; \
git push origin "$$new"