VERSION := $(shell grep -m1 '^version' Cargo.toml | cut -d '"' -f2)

release: src
	cargo build --release

static-release: src
	cargo build --release --target x86_64-unknown-linux-musl

install: src
	cargo install --path .

doc: src
	cargo doc --open

test: src
	- rm -rf coverage
	- mkdir -p coverage
	CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='coverage/cargo-test-%p-%m.profraw' cargo test
	grcov . --binary-path ./target/debug/deps/ -s . -t html --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/
	- open target/coverage/html/index.html
	- rm -rf coverage

merge:
	- git checkout main && git merge develop
	- git commit -m "Merge $(VERSION)"
	- git tag v$(VERSION)
	- git push origin v$(VERSION) && git push && git checkout develop
