github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/Makefile (about)

     1  
     2  default: build
     3  
     4  QRI_VERSION?="0.10.1-dev"
     5  
     6  BUILD_FLAGS?=CGO_ENABLED=0
     7  PKG=$(shell go list ./version)
     8  GOLANG_VERSION=$(shell go version | awk '{print $$3}')
     9  
    10  require-goversion:
    11  # Parse version from go.mod, remove space so it matches `go version`
    12  	$(eval minver := $(shell grep "^go" go.mod | tr -s 'go ' 'go'))
    13  # Magic happens. Sort using "." as the tab, keyed by groups of numbers,
    14  # take the smallest.
    15  	$(eval match := $(shell echo "$(minver)\n$(GOLANG_VERSION)" | sort -t '.' -k 1,1 -k 2,2 -g -r | head -n 1))
    16  # If the minimum version either matches exactly what we have, or does not match
    17  # the result of the magic sort above, we're okay. Otherwise, our binary's
    18  # version isn't good enough: error.
    19  	@if [ "$(GOLANG_VERSION)" != "$(minver)" ]; then \
    20  		if [ "$(match)" == "$(minver)" ]; then \
    21  			echo "Error: invalid go version $(GOLAND_VERSION), need $(minver)"; exit 1; \
    22  		fi; \
    23  	fi;
    24  
    25  require-govvv:
    26  ifeq (,$(shell which govvv))
    27  	@echo "installing govvv"
    28  	$(shell go install github.com/ahmetb/govvv)
    29  endif
    30  
    31  build: require-goversion require-govvv
    32  	$(BUILD_FLAGS) go build -ldflags="-X ${PKG}.GolangVersion=${GOLANG_VERSION} $(shell govvv -flags -pkg $(PKG) -version $(QRI_VERSION))" .
    33  
    34  install: require-goversion require-govvv
    35  	$(BUILD_FLAGS) go install -ldflags="-X ${PKG}.GolangVersion=${GOLANG_VERSION} $(shell govvv -flags -pkg $(PKG) -version $(QRI_VERSION))" .
    36  .PHONY: install
    37  
    38  dscache_fbs:
    39  	cd dscache && flatc --go def.fbs
    40  
    41  workdir:
    42  	mkdir -p workdir
    43  
    44  lint:
    45  	golint ./...
    46  
    47  test:
    48  	go test ./... -v --coverprofile=coverage.txt --covermode=atomic
    49  
    50  test-all-coverage:
    51  	./.circleci/cover.test.sh
    52  
    53  cli-docs:
    54  	cd docs && go run . --dir ../temp --filename cli_commands.md
    55  
    56  api-spec:
    57  	cd docs && go run . --dir ../temp --apiOnly
    58  
    59  serve-api-docs:
    60  	cd docs && go run . --http :2502
    61  
    62  update-changelog:
    63  	conventional-changelog -p angular -i CHANGELOG.md -s