Files
Hein 04711cf7b2
CI / Test (push) Successful in 28s
CI / Build (push) Successful in 25s
fix(cmd): handle errors and improve output formatting
* update error handling in various commands to use blank identifier
* enhance output formatting for better readability
* add golangci-lint to Makefile for linting checks
2026-07-01 12:53:25 +02:00

61 lines
2.0 KiB
Makefile

APP := pgtidy
CMD := ./cmd/pgtidy
DIST := dist
.PHONY: build test lint vet fmt clean release release-version snapshot vscode-compile vscode-package
## build: compile binary for the current platform
build:
go build -trimpath -ldflags "-s -w -X main.version=$$(git describe --tags --abbrev=0 2>/dev/null || echo dev)" -o $(DIST)/$(APP) $(CMD)
## test: run tests (incl. corpus safety harness)
test:
go test ./...
## vet: static analysis
vet:
go vet ./...
## fmt: format Go code
fmt:
go fmt ./...
## lint: vet + format check + golangci-lint
lint: vet
test -z "$$(gofmt -l .)" || (echo "gofmt needed:"; gofmt -l .; exit 1)
golangci-lint run ./...
## clean: remove build artifacts
clean:
rm -rf $(DIST)
## snapshot: build multi-platform binaries without publishing (requires goreleaser)
snapshot:
goreleaser release --snapshot --clean
## release: auto-increment patch version, update package files, tag, and push
release:
@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))"; \
PKGVER="$$MAJOR.$$MINOR.$$((PATCH + 1))"; \
echo "Current: $$CURRENT → Next: $$NEXT"; \
sed -i "s/^pkgver=.*/pkgver=$$PKGVER/" linux/arch/PKGBUILD; \
sed -i "s/^Version:.*/Version: $$PKGVER/" linux/centos/pgtidy.spec; \
git add linux/arch/PKGBUILD linux/centos/pgtidy.spec; \
git commit -m "chore(release): bump version to $$PKGVER"; \
git tag -a "$$NEXT" -m "Release $$NEXT"; \
git push origin HEAD "$$NEXT"; \
echo "Pushed $$NEXT — release workflow triggered"
## vscode-compile: compile the VSCode extension TypeScript
vscode-compile:
cp -r assets editors/vscode/assets
cd editors/vscode && pnpm install && pnpm run build
## vscode-package: build the .vsix package
vscode-package: vscode-compile
cd editors/vscode && pnpm run package