github.com/polygon-io/client-go@v1.16.4/Makefile (about) 1 .DEFAULT_GOAL := help 2 TARGET_MAX_CHAR_NUM := 20 3 VERSION := "" 4 5 GREEN := $(shell tput -Txterm setaf 2) 6 YELLOW := $(shell tput -Txterm setaf 3) 7 WHITE := $(shell tput -Txterm setaf 7) 8 RESET := $(shell tput -Txterm sgr0) 9 10 .PHONY: help fmt lint test rest-example ws-example test-coverage display-coverage release 11 12 ## Show help 13 help: 14 @awk '/^[a-zA-Z\-_0-9]+:/ { \ 15 helpMessage = match(lastLine, /^## (.*)/); \ 16 if (helpMessage) { \ 17 helpCommand = substr($$1, 0, index($$1, ":")-1); \ 18 helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ 19 printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ 20 } \ 21 } \ 22 { lastLine = $$0 }' $(MAKEFILE_LIST) 23 24 ## Format 25 fmt: 26 @echo Formatting 27 @go fmt ./... 28 29 ## Lint with golangci-lint 30 lint: 31 @echo Linting 32 @golangci-lint run --no-config --issues-exit-code=0 --timeout=5m 33 34 ## Run the tests 35 test: 36 @echo Running tests 37 @go test -race -v ./... 38 39 ## Update the REST API spec 40 rest-spec: 41 @echo Updating the REST API spec 42 @go run .polygon/rest.go https://api.polygon.io/openapi 43 44 ## Update the WebSocket API spec 45 ws-spec: 46 @echo Updating the WebSocket API spec 47 @curl https://api.polygon.io/specs/websocket.json > .polygon/websocket.json 48 49 ## Run the REST example 50 rest-example: 51 @echo Running the REST example 52 @go run rest/example/main.go 53 54 ## Run the REST example 55 launchpad-example: 56 @echo Running the Launchpad example 57 @go run rest/example/launchpad/main.go 58 59 ## Run the WebSocket example 60 ws-example: 61 @echo Running the WebSocket example 62 @go run websocket/example/main.go 63 64 ## Run the tests with coverage 65 test-coverage: 66 @echo Running tests with coverage 67 @go test ./... -short -coverprofile=cover.out -covermode=atomic -coverpkg=./... 68 69 ## Display test coverage 70 display-coverage: 71 @echo Displaying test coverage 72 @go tool cover -html=cover.out 73 74 ## Publish a new release (usage: make release VERSION={VERSION_TAG}) 75 release: fmt lint test 76 @echo Tagging release with version '${VERSION}' 77 @[[ "${VERSION}" == v* ]] || { echo "Must pass a version tag starting with 'v' (e.g. 'make release VERSION=v0.1.0')" ; exit 1; } 78 @sed -i.bak '/const clientVersion/s/.*/const clientVersion = "${VERSION}"/' rest/client/client.go && rm rest/client/client.go.bak 79 @git reset && git add -p rest/client/client.go 80 @git checkout -b stage-${VERSION} 81 @git commit -m "update client version tag to '${VERSION}'" 82 @echo Creating and merging a PR 83 @gh pr create --fill && gh pr merge --admin --squash --delete-branch 84 @echo Publishing a release 85 @gh release create ${VERSION}