set shell := ["bash", "-uc"]

export TAG := `cat Cargo.toml | grep '^version =' | cut -d " " -f3 | xargs`

# prints out the currently set version
version:
    #!/usr/bin/env bash
    echo "v$TAG"


# makes sure clippy is fine for each example
clippy-examples:
    #!/usr/bin/env bash
    set -euxo pipefail

    cd examples/actix-web
    cargo +nightly clippy -- -D warnings

    cd ../axum
    cargo +nightly clippy -- -D warnings

    cd ../generic
    cargo +nightly clippy -- -D warnings


# clippy lint + check with minimal versions from nightly
check: clippy-examples
    #!/usr/bin/env bash
    set -euxo pipefail
    clear
    cargo update

    cargo +nightly clippy -- -D warnings
    cargo +nightly clippy --features actix-web -- -D warnings
    cargo +nightly clippy --features axum -- -D warnings

    cargo minimal-versions check
    cargo minimal-versions check --features actix-web
    cargo minimal-versions check --features axum


# runs the full set of tests
test:
    #!/usr/bin/env bash
    set -euxo pipefail
    clear
    cargo test
    echo All tests successful


# builds the code
build:
    #!/usr/bin/env bash
    set -euxo pipefail
    # build as musl to make sure this works
    cargo build --target x86_64-unknown-linux-musl


# verifies the MSRV - Note: Currently, you cannot specify features for this -> add features to default beforehand
msrv-verify:
    cargo msrv verify


# find's the new MSRV, if it needs a bump
msrv-find:
    cargo msrv --min 1.70.0


# makes sure everything is fine
verfiy-is-clean: check test build msrv-verify
    #!/usr/bin/env bash
    set -euxo pipefail

    # make sure everything has been committed
    git diff --exit-code

    echo all good


# publishes the current version to cargo.io
publish: verfiy-is-clean
    #!/usr/bin/env bash
    set -euxo pipefail
    cargo publish
