NAME := borer-core
VERSION := `git describe --dirty`
COMMIT := `git rev-parse HEAD`

.PHONY: build

build:
	cargo build --verbose --release

clean:
	cargo clean

test:
	cargo test --verbose --all

test-all:
	cargo test --verbose --all --all-features

check:
	cargo check
	cargo fmt --check -v 
	cargo clippy -- -D warnings

check-all:
	cargo check --all-features
	cargo fmt --check -v 
	cargo clippy --all-features -- -D warnings

fix:
	cargo clippy --all --fix --allow-dirty --allow-staged
	cargo fmt

publish:
	cargo doc
	cargo publish --registry crates-io --allow-dirty

release:
	@VERSION=$$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/'); \
	MAJOR=$$(echo $$VERSION | cut -d'.' -f1); \
	MINOR=$$(echo $$VERSION | cut -d'.' -f2); \
	PATCH=$$(echo $$VERSION | cut -d'.' -f3); \
	NEW_PATCH=$$((PATCH + 1)); \
	NEW_VERSION="$$MAJOR.$$MINOR.$$NEW_PATCH"; \
	echo "Updating version from $$VERSION to $$NEW_VERSION"; \
	sed -i '' "s/^version = \".*\"/version = \"$$NEW_VERSION\"/" Cargo.toml; \
	make check
	git commit -a -m "release: bump version to $$NEW_VERSION"; \
	git push; \
	cargo doc; \
	cargo publish --registry crates-io


