-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (45 loc) · 1.78 KB
/
Makefile
File metadata and controls
55 lines (45 loc) · 1.78 KB
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
COMMIT_HASH = $(shell git rev-parse HEAD)
.PHONY: build
build:
go build -ldflags "-s -w -X github.com/isokolovskii/commitizen/internal/version.commit=$(COMMIT_HASH)" -o commitizen
.PHONY: build-with-coverage
build-with-coverage:
go build -cover -ldflags "-s -w -X github.com/isokolovskii/commitizen/internal/version.commit=$(COMMIT_HASH)" -o commitizen
install: build
ifeq ($(shell go env GOOS),windows)
copy commitizen $(shell go env GOPATH)\bin\commitizen.exe
else
cp commitizen $$(go env GOPATH)/bin
endif
.PHONY: test
test:
go test -cpu 24 -race -count=1 -timeout=30s ./...
.PHONY: bench
bench:
go test -cpu 24 -race -run=Bench -bench=. ./...
GOLANGCI_LINT_BIN := $(shell go env GOPATH)/bin/golangci-lint
.PHONY: lint
lint: $(GOLANGCI_LINT_BIN)
$(GOLANGCI_LINT_BIN) run
$(GOLANGCI_LINT_BIN):
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v2.6.2
.ONESHELL:
version:
@if [ "$$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then \
echo "Release can only be created from the main branch"; \
exit 1; \
fi
@if ! command -v git-cliff &> /dev/null; then \
echo "git-cliff is not installed. Please install it from https://git-cliff.org/docs/installation/"; \
exit 1; \
fi
@version=$$(git cliff --bumped-version 2>/dev/null); \
echo "Bumping to version $$version"; \
sed -i '' "s/version = .*/version = \"$$version\"/" internal/version/version.go; \
sed -i '' "s/go install github.com\/isokolovskii\/commitizen@.*/go install github.com\/isokolovskii\/commitizen@$$version/" README.md; \
git cliff --bump -o CHANGELOG.md; \
git add internal/version/version.go README.md CHANGELOG.md; \
git commit -m "chore(release): $$version"; \
git tag "$$version"; \
git push origin main; \
git push origin $$version;