mirror of
https://gitea.com/jolheiser/sip
synced 2024-11-22 19:51:58 +01:00
df58f223f2
Exclude Match from gocognit Add search filters Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: jolheiser <john.olheiser@gmail.com> Reviewed-on: https://gitea.com/jolheiser/sip/pulls/8
86 lines
2.5 KiB
Makefile
86 lines
2.5 KiB
Makefile
DIST := dist
|
|
GO ?= go
|
|
SHASUM ?= shasum -a 256
|
|
|
|
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.6; \
|
|
fi
|
|
golangci-lint run --timeout 5m
|
|
|
|
.PHONY: fmt
|
|
fmt:
|
|
$(GO) fmt ./...
|
|
|
|
.PHONY: test
|
|
test:
|
|
$(GO) test -race ./...
|
|
|
|
.PHONY: release
|
|
release: release-dirs check-xgo release-windows release-linux release-darwin release-copy release-compress release-check
|
|
|
|
.PHONY: check-xgo
|
|
check-xgo:
|
|
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
$(GO) get -u src.techknowlogick.com/xgo; \
|
|
fi
|
|
|
|
.PHONY: release-dirs
|
|
release-dirs:
|
|
mkdir -p $(DIST)/binaries $(DIST)/release
|
|
|
|
.PHONY: release-windows
|
|
release-windows:
|
|
xgo -dest $(DIST)/binaries -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out sip-$(VERSION) .
|
|
ifeq ($(CI),drone)
|
|
cp /build/* $(DIST)/binaries
|
|
endif
|
|
|
|
.PHONY: release-linux
|
|
release-linux:
|
|
xgo -dest $(DIST)/binaries -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/mips64le,linux/mips,linux/mipsle' -out sip-$(VERSION) .
|
|
ifeq ($(CI),drone)
|
|
cp /build/* $(DIST)/binaries
|
|
endif
|
|
|
|
.PHONY: release-darwin
|
|
release-darwin:
|
|
xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out sip-$(VERSION) .
|
|
ifeq ($(CI),drone)
|
|
cp /build/* $(DIST)/binaries
|
|
endif
|
|
|
|
.PHONY: release-copy
|
|
release-copy:
|
|
cd $(DIST); for file in `find /build -type f -name "*"`; do cp $${file} ./release/; done;
|
|
|
|
.PHONY: release-check
|
|
release-check:
|
|
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
|
|
|
|
.PHONY: release-compress
|
|
release-compress:
|
|
@hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
$(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \
|
|
fi
|
|
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
|