From a8015d618b9178ac6f0335b4e2c2072fbcb8a0c0 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Fri, 8 Aug 2025 14:26:03 +0000 Subject: [PATCH] chore: Use `nushell` as a script interpreter Signed-off-by: Awiteb --- justfile | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/justfile b/justfile index 7d748f1..0957b92 100644 --- a/justfile +++ b/justfile @@ -4,11 +4,16 @@ # - Linux distribution # - just (Of course) # - cargo (For the build and tests) +# - mdbook () +# - git-cliff () +# - taplo () +# - cargo-msrv () +# - nushell () set quiet set unstable set shell := ["/usr/bin/env", "bash", "-c"] -set script-interpreter := ["/usr/bin/env", "bash"] +set script-interpreter := ["/usr/bin/env", "nu"] JUST_EXECUTABLE := "just -u -f " + justfile() header := "Available tasks:\n" @@ -32,7 +37,7 @@ ci: && msrv _done_ci cargo build -q echo "🔍 Checking code formatting..." cargo fmt -q -- --check - RUST_LOG=none taplo fmt --check --config ./.taplo.toml || (echo "❌Toml files is not properly formatted" && exit 1) + RUST_LOG=none taplo fmt --check --config "./.taplo.toml" || (echo "❌Toml files is not properly formatted" && exit 1) echo "🧹 Running linter checks..." cargo clippy -q -- -D warnings echo "🧪 Running tests..." @@ -50,41 +55,45 @@ _done_ci: # Update the changelog [script] changelog: - OLD_HASH=$(sha256sum CHANGELOG.md | head -c 64) - git-cliff > CHANGELOG.md - NEW_HASH=$(sha256sum CHANGELOG.md | head -c 64) - if [[ $OLD_HASH != $NEW_HASH ]]; then - git add CHANGELOG.md - git commit -m 'chore(changelog): Update the changelog' - echo 'The changes have been added to the changelog file and committed' - else - echo 'No changes have been added to the changelog' - fi + def get_hash [] { open "./CHANGELOG.md" | hash sha256 } + + let old_hash = get_hash + git-cliff out> "CHANGELOG.md" + + if old_hash != get_hash { + git add "CHANGELOG.md" + git commit -m "chore(changelog): Update the changelog" + print "The changes have been added to the changelog file and committed" + } else { + print "No changes have been added to the changelog" + } # Releases a new version of n34. Requires a clean file tree with no uncommitted changes. [script] release version: - set -e - TAG_MSG="Version {{ version }}$(git-cliff --strip all --unreleased --body '{{ tag_change_body }}')" - sed -i "s/^version\s*= \".*\"/version = \"{{ version }}\"/" ./Cargo.toml - taplo fmt --config ./.taplo.toml ./Cargo.toml + let tag_msg = "Version {{ version }}" + (git-cliff --strip all --unreleased --body '{{ tag_change_body }}') + mut cargo_file = open "Cargo.toml" + + $cargo_file.package.version = "{{ version }}" + $cargo_file | save -f "Cargo.toml" + + RUST_LOG=none taplo fmt --config "./.taplo.toml" {{ JUST_EXECUTABLE }} ci - git-cliff -t "v{{ version }}" > CHANGELOG.md + git-cliff -t "v{{ version }}" out> "./CHANGELOG.md" git add . - git commit -m 'chore: Bump the version to `v{{ version }}`' - git tag -s -m "$TAG_MSG" "v{{ version }}" + git commit -m "chore: Bump the version to `v{{ version }}`" + git tag -s -m $tag_msg "v{{ version }}" git push origin master --tags cargo publish # Deploy the book to Github Pages -[script] deploy: mdbook build --dest-dir {{ BOOK_DEST_DIR }} cd {{ BOOK_DEST_DIR }} git init . git checkout -B gh-pages - touch .nojekyll - echo "n34.dev" > CNAME + touch ".nojekyll" + echo "n34.dev" > "CNAME" git add . git commit -m "Deploy the book to github pages"