mirror of
https://gitea.com/jolheiser/sip
synced 2024-11-22 19:51:58 +01:00
35 lines
780 B
Makefile
35 lines
780 B
Makefile
|
GO ?= go
|
||
|
|
||
|
ifneq ($(DRONE_TAG),)
|
||
|
VERSION ?= $(subst v,,$(DRONE_TAG))
|
||
|
LONG_VERSION ?= $(VERSION)
|
||
|
else
|
||
|
ifneq ($(DRONE_BRANCH),)
|
||
|
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
|
||
|
else
|
||
|
VERSION ?= master
|
||
|
endif
|
||
|
LONG_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
|
||
|
endif
|
||
|
|
||
|
LDFLAGS := $(LDFLAGS) -X "main.Version=$(LONG_VERSION)"
|
||
|
|
||
|
.PHONY: build
|
||
|
build:
|
||
|
$(GO) build -ldflags '-s -w $(LDFLAGS)'
|
||
|
|
||
|
.PHONY: lint
|
||
|
lint:
|
||
|
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||
|
export BINARY="golangci-lint"; \
|
||
|
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.1; \
|
||
|
fi
|
||
|
golangci-lint run --timeout 5m
|
||
|
|
||
|
.PHONY: fmt
|
||
|
fmt:
|
||
|
$(GO) fmt ./...
|
||
|
|
||
|
.PHONY: test
|
||
|
test:
|
||
|
$(GO) test -race ./...
|