From 930b51b57d53607ccba733d417986e00cc1bb02e Mon Sep 17 00:00:00 2001 From: Stanislav Bogatyrev Date: Tue, 5 Jul 2022 16:56:30 +0300 Subject: [PATCH] [#1578] Minor Makefile fixes - Add VERSION file to make it work without .git folder - Remove obsolete GO111MODULE flag - Move linter version to variable - clean .cache on `make clean` - Move help target to a separate help.mk file Signed-off-by: Stanislav Bogatyrev --- Makefile | 28 ++++++++++------------------ VERSION | 1 + docs/release-instruction.md | 5 +++++ help.mk | 11 +++++++++++ 4 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 VERSION create mode 100644 help.mk diff --git a/Makefile b/Makefile index 676537f4..990e5722 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SHELL = bash REPO ?= $(shell go list -m) -VERSION ?= $(shell git describe --tags --dirty --always) +VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null || cat VERSION 2>/dev/null || echo "develop") BUILD ?= $(shell date -u --iso=seconds) DEBUG ?= false @@ -10,6 +10,7 @@ HUB_IMAGE ?= nspccdev/neofs HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')" GO_VERSION ?= 1.17 +LINT_VERSION ?= 1.46.2 ARCH = amd64 BIN = bin @@ -27,10 +28,12 @@ BINS = $(addprefix $(BIN)/, $(CMDS)) # Just `make` will build all possible binaries all: $(DIRS) $(BINS) +# help target +include help.mk + $(BINS): $(DIRS) dep @echo "⇒ Build $@" CGO_ENABLED=0 \ - GO111MODULE=on \ go build -v -trimpath \ -ldflags "-X $(REPO)/misc.Version=$(VERSION) \ -X $(REPO)/misc.Build=$(BUILD) \ @@ -54,11 +57,9 @@ prepare-release: docker/all dep: @printf "⇒ Download requirements: " CGO_ENABLED=0 \ - GO111MODULE=on \ go mod download && echo OK @printf "⇒ Tidy requirements : " CGO_ENABLED=0 \ - GO111MODULE=on \ go mod tidy -v && echo OK # Regenerate proto files: @@ -112,17 +113,17 @@ fmts: fmt imports # Reformat code fmt: @echo "⇒ Processing gofmt check" - @GO111MODULE=on gofmt -s -w cmd/ pkg/ misc/ + @gofmt -s -w cmd/ pkg/ misc/ # Reformat imports imports: @echo "⇒ Processing goimports check" - @GO111MODULE=on goimports -w cmd/ pkg/ misc/ + @goimports -w cmd/ pkg/ misc/ # Run Unit Test with go test test: @echo "⇒ Running go test" - @GO111MODULE=on go test ./... + @go test ./... # Run linters lint: @@ -134,23 +135,14 @@ docker/lint: -v `pwd`:/src \ -u `stat -c "%u:%g" .` \ --env HOME=/src \ - golangci/golangci-lint:v1.42.1 bash -c 'cd /src/ && make lint' + golangci/golangci-lint:v$(LINT_VERSION) bash -c 'cd /src/ && make lint' # Print version version: @echo $(VERSION) -# Show this help prompt -help: - @echo ' Usage:' - @echo '' - @echo ' make ' - @echo '' - @echo ' Targets:' - @echo '' - @awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort -u - clean: rm -rf vendor + rm -rf .cache rm -rf $(BIN) rm -rf $(RELEASE) diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..6e091670 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v0.28.3 diff --git a/docs/release-instruction.md b/docs/release-instruction.md index c5856537..82dab329 100644 --- a/docs/release-instruction.md +++ b/docs/release-instruction.md @@ -28,6 +28,11 @@ Use `vX.Y.Z` tag for releases and `vX.Y.Z-rc.N` for release candidates following the [semantic versioning](https://semver.org/) standard. Tag must be created from the latest commit of the master branch. +## Update VERSION files + +Make sure the VERSION file contains correct release version. It must be the tag +you have just created. + ## Push changes and release tag to GitHub This step should bypass the default PR mechanism to get a correct result (so diff --git a/help.mk b/help.mk new file mode 100644 index 00000000..c065ec86 --- /dev/null +++ b/help.mk @@ -0,0 +1,11 @@ +.PHONY: help + +# Show this help prompt +help: + @echo ' Usage:' + @echo '' + @echo ' make ' + @echo '' + @echo ' Targets:' + @echo '' + @awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort | uniq