2020-07-20 22:33:29 +08:00
|
|
|
PREFIX ?= /usr/local
|
2021-04-05 23:53:06 +08:00
|
|
|
VERSION ?= $(shell git describe --tags --dirty --always | sed -e 's/^v//')
|
2019-01-13 12:45:25 +08:00
|
|
|
IS_SNAPSHOT = $(if $(findstring -, $(VERSION)),true,false)
|
2020-02-25 07:04:33 +08:00
|
|
|
MAJOR_VERSION = $(word 1, $(subst ., ,$(VERSION)))
|
|
|
|
MINOR_VERSION = $(word 2, $(subst ., ,$(VERSION)))
|
|
|
|
PATCH_VERSION = $(word 3, $(subst ., ,$(word 1,$(subst -, , $(VERSION)))))
|
|
|
|
NEW_VERSION ?= $(MAJOR_VERSION).$(MINOR_VERSION).$(shell echo $$(( $(PATCH_VERSION) + 1)) )
|
2019-01-13 12:45:25 +08:00
|
|
|
|
2021-05-04 00:52:03 +08:00
|
|
|
fix = false
|
|
|
|
ifeq (true,$(fix))
|
|
|
|
FIX = --fix
|
|
|
|
endif
|
|
|
|
|
2020-02-25 06:43:03 +08:00
|
|
|
ACT ?= go run main.go
|
2021-05-04 00:52:03 +08:00
|
|
|
|
|
|
|
HAS_TOKEN = $(if $(test -e ~/.config/github/token),true,false)
|
|
|
|
ifeq (true,$(HAS_TOKEN))
|
|
|
|
export GITHUB_TOKEN := $(shell cat ~/.config/github/token)
|
|
|
|
endif
|
2019-01-16 09:41:02 +08:00
|
|
|
|
2021-08-10 00:07:26 +08:00
|
|
|
.PHONY: pr
|
|
|
|
pr: tidy format-all lint test
|
|
|
|
|
2020-07-26 21:01:01 +08:00
|
|
|
.PHONY: build
|
2020-07-20 22:33:29 +08:00
|
|
|
build:
|
2020-02-25 07:04:33 +08:00
|
|
|
go build -ldflags "-X main.version=$(VERSION)" -o dist/local/act main.go
|
2019-01-13 12:45:25 +08:00
|
|
|
|
2020-09-30 04:39:45 +08:00
|
|
|
.PHONY: format
|
|
|
|
format:
|
|
|
|
go fmt ./...
|
|
|
|
|
2021-08-10 00:07:26 +08:00
|
|
|
.PHONY: format-all
|
|
|
|
format-all:
|
|
|
|
go fmt ./...
|
|
|
|
npx prettier --write .
|
|
|
|
|
2020-07-26 21:01:01 +08:00
|
|
|
.PHONY: test
|
2020-02-25 07:04:33 +08:00
|
|
|
test:
|
2020-09-29 03:03:35 +08:00
|
|
|
go test ./...
|
|
|
|
$(ACT)
|
2019-01-17 16:45:37 +08:00
|
|
|
|
2021-05-04 00:52:03 +08:00
|
|
|
.PHONY: lint-go
|
|
|
|
lint-go:
|
|
|
|
golangci-lint run $(FIX)
|
|
|
|
|
|
|
|
.PHONY: lint-js
|
|
|
|
lint-js:
|
2021-08-10 00:07:26 +08:00
|
|
|
npx standard $(FIX)
|
2021-05-04 00:52:03 +08:00
|
|
|
|
|
|
|
.PHONY: lint-md
|
|
|
|
lint-md:
|
2021-08-10 00:07:26 +08:00
|
|
|
npx markdownlint . $(FIX)
|
2021-05-04 00:52:03 +08:00
|
|
|
|
|
|
|
.PHONY: lint-rest
|
|
|
|
lint-rest:
|
|
|
|
docker run --rm -it \
|
|
|
|
-e 'RUN_LOCAL=true' \
|
|
|
|
-e 'FILTER_REGEX_EXCLUDE=.*testdata/*' \
|
|
|
|
-e 'VALIDATE_BASH=false' \
|
|
|
|
-e 'VALIDATE_DOCKERFILE=false' \
|
|
|
|
-e 'VALIDATE_DOCKERFILE_HADOLINT=false' \
|
|
|
|
-e 'VALIDATE_GO=false' \
|
|
|
|
-e 'VALIDATE_JSCPD=false' \
|
|
|
|
-e 'VALIDATE_SHELL_SHFMT=false' \
|
|
|
|
-v $(PWD):/tmp/lint \
|
|
|
|
github/super-linter
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint: lint-go lint-rest
|
|
|
|
|
|
|
|
.PHONY: lint-fix
|
|
|
|
lint-fix: lint-md lint-go
|
|
|
|
|
|
|
|
.PHONY: fix
|
|
|
|
fix:
|
|
|
|
make lint-fix fix=true
|
|
|
|
|
2021-08-10 00:07:26 +08:00
|
|
|
.PHONY: tidy
|
|
|
|
tidy:
|
|
|
|
go mod tidy
|
|
|
|
|
2020-07-26 21:01:01 +08:00
|
|
|
.PHONY: install
|
2019-01-13 12:45:25 +08:00
|
|
|
install: build
|
2020-07-20 22:33:29 +08:00
|
|
|
@cp dist/local/act $(PREFIX)/bin/act
|
|
|
|
@chmod 755 $(PREFIX)/bin/act
|
2019-01-13 12:45:25 +08:00
|
|
|
@act --version
|
|
|
|
|
2020-07-26 21:01:01 +08:00
|
|
|
.PHONY: installer
|
2019-01-13 12:45:25 +08:00
|
|
|
installer:
|
|
|
|
@GO111MODULE=off go get github.com/goreleaser/godownloader
|
|
|
|
godownloader -r nektos/act -o install.sh
|
|
|
|
|
2020-07-26 21:01:01 +08:00
|
|
|
.PHONY: promote
|
2020-07-20 22:33:29 +08:00
|
|
|
promote:
|
2020-02-25 07:04:33 +08:00
|
|
|
@git fetch --tags
|
|
|
|
@echo "VERSION:$(VERSION) IS_SNAPSHOT:$(IS_SNAPSHOT) NEW_VERSION:$(NEW_VERSION)"
|
2019-01-13 12:45:25 +08:00
|
|
|
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
|
2020-02-25 07:04:33 +08:00
|
|
|
git tag -a -m "releasing v$(NEW_VERSION)" v$(NEW_VERSION)
|
|
|
|
git push origin v$(NEW_VERSION)
|
2021-11-28 02:05:56 +08:00
|
|
|
|
|
|
|
.PHONY: snapshot
|
|
|
|
snapshot:
|
|
|
|
goreleaser build \
|
|
|
|
--rm-dist \
|
|
|
|
--single-target \
|
|
|
|
--snapshot
|