2020-07-20 17:33:29 +03:00
|
|
|
PREFIX ?= /usr/local
|
2021-04-05 18:53:06 +03:00
|
|
|
VERSION ?= $(shell git describe --tags --dirty --always | sed -e 's/^v//')
|
2019-01-13 07:45:25 +03:00
|
|
|
IS_SNAPSHOT = $(if $(findstring -, $(VERSION)),true,false)
|
2020-02-25 02:04:33 +03: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 07:45:25 +03:00
|
|
|
|
2021-05-03 19:52:03 +03:00
|
|
|
fix = false
|
|
|
|
ifeq (true,$(fix))
|
|
|
|
FIX = --fix
|
|
|
|
endif
|
|
|
|
|
2020-02-25 01:43:03 +03:00
|
|
|
ACT ?= go run main.go
|
2021-05-03 19:52:03 +03: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 04:41:02 +03:00
|
|
|
|
2021-08-09 19:07:26 +03:00
|
|
|
.PHONY: pr
|
|
|
|
pr: tidy format-all lint test
|
|
|
|
|
2020-07-26 16:01:01 +03:00
|
|
|
.PHONY: build
|
2020-07-20 17:33:29 +03:00
|
|
|
build:
|
2020-02-25 02:04:33 +03:00
|
|
|
go build -ldflags "-X main.version=$(VERSION)" -o dist/local/act main.go
|
2019-01-13 07:45:25 +03:00
|
|
|
|
2020-09-29 23:39:45 +03:00
|
|
|
.PHONY: format
|
|
|
|
format:
|
|
|
|
go fmt ./...
|
|
|
|
|
2021-08-09 19:07:26 +03:00
|
|
|
.PHONY: format-all
|
|
|
|
format-all:
|
|
|
|
go fmt ./...
|
|
|
|
npx prettier --write .
|
|
|
|
|
2020-07-26 16:01:01 +03:00
|
|
|
.PHONY: test
|
2020-02-25 02:04:33 +03:00
|
|
|
test:
|
2020-09-28 22:03:35 +03:00
|
|
|
go test ./...
|
|
|
|
$(ACT)
|
2019-01-17 11:45:37 +03:00
|
|
|
|
2021-05-03 19:52:03 +03:00
|
|
|
.PHONY: lint-go
|
|
|
|
lint-go:
|
|
|
|
golangci-lint run $(FIX)
|
|
|
|
|
|
|
|
.PHONY: lint-js
|
|
|
|
lint-js:
|
2021-08-09 19:07:26 +03:00
|
|
|
npx standard $(FIX)
|
2021-05-03 19:52:03 +03:00
|
|
|
|
|
|
|
.PHONY: lint-md
|
|
|
|
lint-md:
|
2021-08-09 19:07:26 +03:00
|
|
|
npx markdownlint . $(FIX)
|
2021-05-03 19:52:03 +03:00
|
|
|
|
|
|
|
.PHONY: lint-rest
|
|
|
|
lint-rest:
|
|
|
|
docker run --rm -it \
|
|
|
|
-v $(PWD):/tmp/lint \
|
2021-12-22 20:29:43 +03:00
|
|
|
-e GITHUB_STATUS_REPORTER=false \
|
|
|
|
-e GITHUB_COMMENT_REPORTER=false \
|
|
|
|
megalinter/megalinter-go:v5
|
2021-05-03 19:52:03 +03:00
|
|
|
|
|
|
|
.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-09 19:07:26 +03:00
|
|
|
.PHONY: tidy
|
|
|
|
tidy:
|
|
|
|
go mod tidy
|
|
|
|
|
2020-07-26 16:01:01 +03:00
|
|
|
.PHONY: install
|
2019-01-13 07:45:25 +03:00
|
|
|
install: build
|
2020-07-20 17:33:29 +03:00
|
|
|
@cp dist/local/act $(PREFIX)/bin/act
|
|
|
|
@chmod 755 $(PREFIX)/bin/act
|
2019-01-13 07:45:25 +03:00
|
|
|
@act --version
|
|
|
|
|
2020-07-26 16:01:01 +03:00
|
|
|
.PHONY: installer
|
2019-01-13 07:45:25 +03:00
|
|
|
installer:
|
|
|
|
@GO111MODULE=off go get github.com/goreleaser/godownloader
|
|
|
|
godownloader -r nektos/act -o install.sh
|
|
|
|
|
2020-07-26 16:01:01 +03:00
|
|
|
.PHONY: promote
|
2020-07-20 17:33:29 +03:00
|
|
|
promote:
|
2020-02-25 02:04:33 +03:00
|
|
|
@git fetch --tags
|
|
|
|
@echo "VERSION:$(VERSION) IS_SNAPSHOT:$(IS_SNAPSHOT) NEW_VERSION:$(NEW_VERSION)"
|
2019-01-13 07:45:25 +03: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
|
2023-01-15 13:30:41 +03:00
|
|
|
echo -n $(NEW_VERSION) > VERSION
|
|
|
|
git add VERSION
|
2023-01-16 20:43:53 +03:00
|
|
|
git commit -m "chore: bump VERSION to $(NEW_VERSION)"
|
2020-02-25 02:04:33 +03:00
|
|
|
git tag -a -m "releasing v$(NEW_VERSION)" v$(NEW_VERSION)
|
2023-01-16 20:57:35 +03:00
|
|
|
git push origin master
|
|
|
|
git push origin v$(NEW_VERSION)
|
2021-11-27 21:05:56 +03:00
|
|
|
|
|
|
|
.PHONY: snapshot
|
|
|
|
snapshot:
|
|
|
|
goreleaser build \
|
2023-07-10 20:15:16 +03:00
|
|
|
--clean \
|
2021-11-27 21:05:56 +03:00
|
|
|
--single-target \
|
|
|
|
--snapshot
|
2023-01-15 13:30:41 +03:00
|
|
|
|
|
|
|
.PHONY: clean all
|