Skip to content

Commit d7b8003

Browse files
author
Camilo Aguilar
committed
Add clean target and make ldflags a variable
1 parent 48cae9d commit d7b8003

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
NAME := postgres-exporter
22
VERSION := v0.2.2
3+
LDFLAGS := -ldflags "-X main.Version=$(VERSION)"
34

45
help: ## Shows this help text
56
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
67

78
dev: ## Builds dev binary
8-
go build -ldflags "-X main.Version=$(VERSION)"
9+
go build $(LDFLAGS)
910

1011
build: ## Builds binary for all supported platforms
1112
@rm -rf build/
@@ -18,7 +19,7 @@ build: ## Builds binary for all supported platforms
1819
./...
1920

2021
install: ## Locally installs dev binary
21-
go install -ldflags "-X main.Version=$(VERSION)"
22+
go install $(LDFLAGS)
2223

2324
deps: ## Installs dev dependencies
2425
go get github.com/c4milo/github-release
@@ -42,4 +43,7 @@ release: dist ## Pushes up distributable artifacts to Github Releases
4243
github-release c4milo/$(NAME) $(VERSION) "$$(git rev-parse --abbrev-ref HEAD)" "**Changelog**<br/>$$changelog" 'dist/*'; \
4344
git pull
4445

45-
.PHONY: build dev dist install deps release
46+
clean: ## Runs go clean
47+
go clean $(LDFLAGS)
48+
49+
.PHONY: build dev clean dist install deps release

0 commit comments

Comments
 (0)