github.com/nektos/act@v0.2.63/Makefile (about)

     1  PREFIX ?= /usr/local
     2  VERSION ?= $(shell git describe --tags --dirty --always | sed -e 's/^v//')
     3  IS_SNAPSHOT = $(if $(findstring -, $(VERSION)),true,false)
     4  MAJOR_VERSION = $(word 1, $(subst ., ,$(VERSION)))
     5  MINOR_VERSION = $(word 2, $(subst ., ,$(VERSION)))
     6  PATCH_VERSION = $(word 3, $(subst ., ,$(word 1,$(subst -, , $(VERSION)))))
     7  NEW_VERSION ?= $(MAJOR_VERSION).$(MINOR_VERSION).$(shell echo $$(( $(PATCH_VERSION) + 1)) )
     8  
     9  fix = false
    10  ifeq (true,$(fix))
    11  	FIX = --fix
    12  endif
    13  
    14  ACT ?= go run main.go
    15  
    16  HAS_TOKEN = $(if $(test -e ~/.config/github/token),true,false)
    17  ifeq (true,$(HAS_TOKEN))
    18  	export GITHUB_TOKEN := $(shell cat ~/.config/github/token)
    19  endif
    20  
    21  .PHONY: pr
    22  pr: tidy format-all lint test
    23  
    24  .PHONY: build
    25  build:
    26  	go build -ldflags "-X main.version=$(VERSION)" -o dist/local/act main.go
    27  
    28  .PHONY: format
    29  format:
    30  	go fmt ./...
    31  
    32  .PHONY: format-all
    33  format-all:
    34  	go fmt ./...
    35  	npx prettier --write .
    36  
    37  .PHONY: test
    38  test:
    39  	go test ./...
    40  	$(ACT)
    41  
    42  .PHONY: lint-go
    43  lint-go:
    44  	golangci-lint run $(FIX)
    45  
    46  .PHONY: lint-js
    47  lint-js:
    48  	npx standard $(FIX)
    49  
    50  .PHONY: lint-md
    51  lint-md:
    52  	npx markdownlint . $(FIX)
    53  
    54  .PHONY: lint-rest
    55  lint-rest:
    56  	docker run --rm -it \
    57  		-v $(PWD):/tmp/lint \
    58  		-e GITHUB_STATUS_REPORTER=false \
    59  		-e GITHUB_COMMENT_REPORTER=false \
    60  		megalinter/megalinter-go:v5
    61  
    62  .PHONY: lint
    63  lint: lint-go lint-rest
    64  
    65  .PHONY: lint-fix
    66  lint-fix: lint-md lint-go
    67  
    68  .PHONY: fix
    69  fix:
    70  	make lint-fix fix=true
    71  
    72  .PHONY: tidy
    73  tidy:
    74  	go mod tidy
    75  
    76  .PHONY: install
    77  install: build
    78  	@cp dist/local/act $(PREFIX)/bin/act
    79  	@chmod 755 $(PREFIX)/bin/act
    80  	@act --version
    81  
    82  .PHONY: installer
    83  installer:
    84  	@GO111MODULE=off go get github.com/goreleaser/godownloader
    85  	godownloader -r nektos/act -o install.sh
    86  
    87  .PHONY: promote
    88  promote:
    89  	@git fetch --tags
    90  	@echo "VERSION:$(VERSION) IS_SNAPSHOT:$(IS_SNAPSHOT) NEW_VERSION:$(NEW_VERSION)"
    91  ifeq (false,$(IS_SNAPSHOT))
    92  	@echo "Unable to promote a non-snapshot"
    93  	@exit 1
    94  endif
    95  ifneq ($(shell git status -s),)
    96  	@echo "Unable to promote a dirty workspace"
    97  	@exit 1
    98  endif
    99  	echo -n $(NEW_VERSION) > VERSION
   100  	git add VERSION
   101  	git commit -m "chore: bump VERSION to $(NEW_VERSION)"
   102  	git tag -a -m "releasing v$(NEW_VERSION)" v$(NEW_VERSION)
   103  	git push origin master
   104  	git push origin v$(NEW_VERSION)
   105  
   106  .PHONY: snapshot
   107  snapshot:
   108  	goreleaser build \
   109  		--clean \
   110  		--single-target \
   111  		--snapshot
   112  
   113  .PHONY: clean all