1VERSION ?= 0.0.0 2TODAY=$(shell date +'%Y/%m/%d') 3 4.DEFAULT_GOAL := help 5 6build: # builds for the current platform 7 go install -ldflags "-X github.com/git-town/git-town/src/cmd.version=v${VERSION}-dev -X github.com/git-town/git-town/src/cmd.buildDate=${TODAY}" 8 9cuke: build # runs the new Godog-based feature tests 10 @env GOGC=off go test . -v -count=1 11 12cuke-prof: build # creates a flamegraph 13 env GOGC=off go test . -v -cpuprofile=godog.out 14 @rm git-town.test 15 @echo Please open https://www.speedscope.app and load the file godog.out 16 17docs: # tests the documentation 18 ${CURDIR}/text-run/node_modules/.bin/text-run --offline 19 20fix: fix-go fix-md # auto-fixes lint issues in all languages 21 22fix-go: # auto-fixes all Go lint issues 23 gofmt -s -w ./src ./test 24 25fix-md: # auto-fixes all Markdown lint issues 26 ${CURDIR}/tools/prettier/node_modules/.bin/prettier --write . 27 28help: # prints all make targets 29 @cat Makefile | grep '^[^ ]*:' | grep -v '.PHONY' | grep -v help | sed 's/:.*#/#/' | column -s "#" -t 30 31msi: # compiles the MSI installer for Windows 32 rm -f git-town*.msi 33 go build -ldflags "-X github.com/git-town/git-town/src/cmd.version=v${VERSION} -X github.com/git-town/git-town/src/cmd.buildDate=${TODAY}" 34 go-msi make --msi dist/git-town_${VERSION}_windows_intel_64.msi --version ${VERSION} --src installer/templates/ --path installer/wix.json 35 @rm git-town.exe 36 37lint: lint-go lint-md # lints all the source code 38 39lint-go: # lints the Go files 40 golangci-lint run src/... test/... 41 42lint-md: # lints the Markdown files 43 ${CURDIR}/tools/prettier/node_modules/.bin/prettier -l . 44 45release-linux: # creates a new release 46 # cross-compile the binaries 47 goreleaser --rm-dist 48 49 # create GitHub release with files in alphabetical order 50 hub release create --draft --browse --message v${VERSION} \ 51 -a dist/git-town_${VERSION}_linux_intel_64.deb \ 52 -a dist/git-town_${VERSION}_linux_intel_64.rpm \ 53 -a dist/git-town_${VERSION}_linux_intel_64.tar.gz \ 54 -a dist/git-town_${VERSION}_linux_arm_64.deb \ 55 -a dist/git-town_${VERSION}_linux_arm_64.rpm \ 56 -a dist/git-town_${VERSION}_linux_arm_64.tar.gz \ 57 -a dist/git-town_${VERSION}_macOS_intel_64.tar.gz \ 58 -a dist/git-town_${VERSION}_windows_intel_64.zip \ 59 v${VERSION} 60 61release-win: msi # adds the Windows installer to the release 62 hub release edit --browse --message v${VERSION} \ 63 -a dist/git-town_${VERSION}_windows_intel_64.msi 64 v${VERSION} 65 66setup: setup-go # the setup steps necessary on developer machines 67 cd tools/prettier && yarn install 68 cd text-run && yarn install 69 70setup-go: 71 @(cd .. && GO111MODULE=on go get github.com/cucumber/godog/cmd/godog@v0.9.0) 72 @(cd .. && GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.27.0) 73 74stats: # shows code statistics 75 @find . -type f | grep -v '\./node_modules/' | grep -v '\./vendor/' | grep -v '\./.git/' | xargs scc 76 77test: lint docs unit cuke # runs all the tests 78.PHONY: test 79 80test-go: build u lint-go cuke # runs all tests for Golang 81 82test-md: lint-md # runs all Markdown tests 83 84u: # runs only the unit tests for changed code 85 env GOGC=off go test -timeout 30s ./src/... ./test/... 86 87unit: # runs all the unit tests with race detector 88 env GOGC=off go test -count=1 -timeout 60s -race ./src/... ./test/... 89 90update: # updates all dependencies 91 go get -u ./... 92 go mod tidy 93 go mod vendor 94 95website-build: # compiles the website (used during deployment) 96 (cd tools/harp && yarn install) 97 tools/harp/node_modules/.bin/harp compile website/ www 98 99website-dev: # runs a local development server of the website 100 (cd website && ../tools/harp/node_modules/.bin/harp server) 101