-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
102 lines (91 loc) · 3.39 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
95
96
97
98
99
100
101
102
.PHONY: help
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: ## Build release with cargo for the current OS
cargo build --release
.PHONY: lint
lint: ## Run clippy linter
cargo clippy --workspace --tests --all-features -- -D warnings
.PHONY: test
test: ## Run unit tests
RUST_BACKTRACE=1 cargo test
.PHONY: cover
cover: ## Generate test coverage report
docker run \
--security-opt seccomp=unconfined \
-v ${PWD}:/volume \
-e "RUST_BACKTRACE=1" \
xd009642/tarpaulin \
cargo tarpaulin --color auto --out Html --output-dir ./target
open target/tarpaulin-report.html
.PHONY: bench
bench: ## Generate benchmark report
cargo bench --bench parse -- --verbose
open target/criterion/report/index.html
APP = belt
VERSION := $(shell cargo metadata -q | jq -r '.packages[] | select(.name == "$(APP)") | .version')
UNAME_S := $(shell uname -s)
NEXT_VERSION := $(shell echo "$(VERSION)" | awk -F. -v OFS=. '{$$NF += 1 ; print}')
.PHONY: package
package: ## Make release package based on the current OS
ifdef OS # windows
mkdir -p target/package
tar -a -cvf target/package/$(APP)-$(VERSION)-windows-x86_64-msvc.zip \
-C $$PWD/target/x86_64-pc-windows-msvc/release $(APP).exe \
-C $$PWD LICENSE README.md
else ifeq ($(UNAME_S),Darwin) # macOS
mkdir -p target/package
zip -j target/package/$(APP)-$(VERSION)-macos-x86_64.zip \
target/x86_64-apple-darwin/release/$(APP) LICENSE README.md
else ifeq ($(UNAME_S),Linux) # linux
sudo mkdir -p target/package
sudo tar -z -cvf target/package/$(APP)-$(VERSION)-$(arch)-unknown-linux-$(libc).tar.gz \
-C $$PWD/target/$(arch)-unknown-linux-$(libc)/release $(APP) \
-C $$PWD LICENSE README.md
endif
.PHONY: show-version-files
show-version-files: ## Find all files with the current version
@grep -rn --color \
--exclude-dir={target,.git} \
--exclude Cargo.lock \
--fixed-strings '"$(VERSION)"' .
.PHONY: bump-version
bump-version: ## Bump version in files that contain the current version
@echo "👉 Bumping version $(VERSION) -> $(NEXT_VERSION)..."
@echo
@echo "🚀 Create a git branch for the version bump:"
git checkout -b bump-version-$(NEXT_VERSION)
@echo
@echo "🚀 Update version in files:"
@for file in $(shell grep -rl --exclude-dir={target,.git} --exclude Cargo.lock --fixed-strings '"$(VERSION)"' .); do \
echo "✅ In file $$file"; \
sed -i '' -e 's/$(subst .,\.,$(VERSION))/$(NEXT_VERSION)/g' $$file; \
git add $$file; \
done
@echo
@echo "🚀 Update Cargo.lock:"
cargo update
git add Cargo.lock
@echo
@echo "🚀 Bumped version in the following files:"
@make show-version-files
@echo
@echo "🚀 Commit the changes:"
git commit -m "version: bump to $(NEXT_VERSION)"
@echo "🚀 Push the branch to GitHub:"
git push --set-upstream origin bump-version-$(NEXT_VERSION)
@echo
@echo "🎉 Next, create a pull request on GitHub and merge it."
.PHONY: release
release: ## Make a new tag based on the version from Cargo.toml and push to GitHub
@if [[ "$(shell git tag -l)" == *"v$(VERSION)"* ]]; then \
echo "Tag v$(VERSION) already exists"; \
else \
echo "Tagging v$(VERSION) and pushing to GitHub..."; \
git tag -a v$(VERSION) -m "Release v$(VERSION)"; \
git push origin v$(VERSION); \
fi
.PHONY: publish
publish: ## Publish to crates.io
cargo publish --manifest-path dateparser/Cargo.toml --token $(token)