forked from nektos/act
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
94 lines (78 loc) · 2.06 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
PREFIX ?= /usr/local
VERSION ?= $(shell git describe --tags --dirty --always | sed -e 's/^v//')
IS_SNAPSHOT = $(if $(findstring -, $(VERSION)),true,false)
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)) )
fix = false
ifeq (true,$(fix))
FIX = --fix
endif
ACT ?= go run main.go
HAS_TOKEN = $(if $(test -e ~/.config/github/token),true,false)
ifeq (true,$(HAS_TOKEN))
export GITHUB_TOKEN := $(shell cat ~/.config/github/token)
endif
.PHONY: build
build:
go build -ldflags "-X main.version=$(VERSION)" -o dist/local/act main.go
.PHONY: format
format:
go fmt ./...
.PHONY: test
test:
go test ./...
$(ACT)
.PHONY: lint-go
lint-go:
golangci-lint run $(FIX)
.PHONY: lint-js
lint-js:
standard $(FIX)
.PHONY: lint-md
lint-md:
markdownlint . $(FIX)
.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
.PHONY: install
install: build
@cp dist/local/act $(PREFIX)/bin/act
@chmod 755 $(PREFIX)/bin/act
@act --version
.PHONY: installer
installer:
@GO111MODULE=off go get github.com/goreleaser/godownloader
godownloader -r nektos/act -o install.sh
.PHONY: promote
promote:
@git fetch --tags
@echo "VERSION:$(VERSION) IS_SNAPSHOT:$(IS_SNAPSHOT) NEW_VERSION:$(NEW_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
git tag -a -m "releasing v$(NEW_VERSION)" v$(NEW_VERSION)
git push origin v$(NEW_VERSION)