2019-01-13 12:45:25 +08:00
|
|
|
LATEST_VERSION := $(shell git tag -l --sort=creatordate | grep "^v[0-9]*.[0-9]*.[0-9]*$$" | tail -1 | cut -c 2-)
|
|
|
|
ifeq "$(shell git tag -l v$(LATEST_VERSION) --points-at HEAD)" "v$(LATEST_VERSION)"
|
|
|
|
### latest tag points to current commit, this is a release build
|
|
|
|
VERSION ?= $(LATEST_VERSION)
|
|
|
|
else
|
|
|
|
### latest tag points to prior commit, this is a snapshot build
|
|
|
|
MAJOR_VERSION := $(word 1, $(subst ., ,$(LATEST_VERSION)))
|
|
|
|
MINOR_VERSION := $(word 2, $(subst ., ,$(LATEST_VERSION)))
|
|
|
|
PATCH_VERSION := $(word 3, $(subst ., ,$(LATEST_VERSION)))
|
|
|
|
VERSION ?= $(MAJOR_VERSION).$(MINOR_VERSION).$(shell echo $$(( $(PATCH_VERSION) + 1)) )-develop
|
|
|
|
endif
|
|
|
|
IS_SNAPSHOT = $(if $(findstring -, $(VERSION)),true,false)
|
|
|
|
TAG_VERSION = v$(VERSION)
|
|
|
|
|
2019-01-24 03:51:22 +08:00
|
|
|
ACT ?= go run -mod=vendor main.go
|
2019-02-08 01:39:04 +08:00
|
|
|
export GITHUB_TOKEN = $(shell cat ~/.config/github/token)
|
2019-01-16 09:41:02 +08:00
|
|
|
|
2019-01-13 12:45:25 +08:00
|
|
|
check:
|
2020-02-18 13:59:08 +08:00
|
|
|
@golangci-lint run
|
|
|
|
@go test -cover ./...
|
2019-01-13 12:45:25 +08:00
|
|
|
|
2019-01-17 16:45:37 +08:00
|
|
|
build: check
|
2019-01-13 12:45:25 +08:00
|
|
|
$(eval export SNAPSHOT_VERSION=$(VERSION))
|
2019-01-17 16:45:37 +08:00
|
|
|
$(ACT) -ra build
|
|
|
|
|
2019-01-13 12:45:25 +08:00
|
|
|
install: build
|
|
|
|
@cp dist/$(shell go env GOOS)_$(shell go env GOARCH)/act /usr/local/bin/act
|
|
|
|
@chmod 755 /usr/local/bin/act
|
|
|
|
@act --version
|
|
|
|
|
|
|
|
installer:
|
|
|
|
@GO111MODULE=off go get github.com/goreleaser/godownloader
|
|
|
|
godownloader -r nektos/act -o install.sh
|
|
|
|
|
2019-01-24 03:51:22 +08:00
|
|
|
promote: vendor
|
2019-01-13 12:45:25 +08:00
|
|
|
@echo "VERSION:$(VERSION) IS_SNAPSHOT:$(IS_SNAPSHOT) LATEST_VERSION:$(LATEST_VERSION)"
|
|
|
|
ifeq (false,$(IS_SNAPSHOT))
|
|
|
|
@echo "Unable to promote a non-snapshot"
|
|
|
|
@exit 1
|
|
|
|
endif
|
|
|
|
ifneq ($(shell git status -s),)
|
|
|
|
@echo "Unable to promote a dirty workspace"
|
|
|
|
@exit 1
|
|
|
|
endif
|
|
|
|
$(eval NEW_VERSION := $(word 1,$(subst -, , $(TAG_VERSION))))
|
|
|
|
git tag -a -m "releasing $(NEW_VERSION)" $(NEW_VERSION)
|
2019-01-24 03:51:22 +08:00
|
|
|
git push origin $(NEW_VERSION)
|
|
|
|
|
|
|
|
vendor:
|
2019-02-07 14:36:08 +08:00
|
|
|
go mod vendor
|
2019-01-24 03:51:22 +08:00
|
|
|
|
2020-02-11 07:27:05 +08:00
|
|
|
.PHONY: vendor
|