chore: Use nushell as a script interpreter

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-08-08 14:26:03 +00:00
parent 2bcdb29a88
commit a8015d618b

View File

@@ -4,11 +4,16 @@
# - Linux distribution # - Linux distribution
# - just (Of course) <https://github.com/casey/just> # - just (Of course) <https://github.com/casey/just>
# - cargo (For the build and tests) <https://doc.rust-lang.org/cargo/getting-started/installation.html> # - cargo (For the build and tests) <https://doc.rust-lang.org/cargo/getting-started/installation.html>
# - mdbook (<https://rust-lang.github.io/mdBook>)
# - git-cliff (<https://git-cliff.org>)
# - taplo (<https://taplo.tamasfe.dev/>)
# - cargo-msrv (<https://github.com/foresterre/cargo-msrv>)
# - nushell (<https://nushell.sh>)
set quiet set quiet
set unstable set unstable
set shell := ["/usr/bin/env", "bash", "-c"] 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() JUST_EXECUTABLE := "just -u -f " + justfile()
header := "Available tasks:\n" header := "Available tasks:\n"
@@ -32,7 +37,7 @@ ci: && msrv _done_ci
cargo build -q cargo build -q
echo "🔍 Checking code formatting..." echo "🔍 Checking code formatting..."
cargo fmt -q -- --check 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..." echo "🧹 Running linter checks..."
cargo clippy -q -- -D warnings cargo clippy -q -- -D warnings
echo "🧪 Running tests..." echo "🧪 Running tests..."
@@ -50,41 +55,45 @@ _done_ci:
# Update the changelog # Update the changelog
[script] [script]
changelog: changelog:
OLD_HASH=$(sha256sum CHANGELOG.md | head -c 64) def get_hash [] { open "./CHANGELOG.md" | hash sha256 }
git-cliff > CHANGELOG.md
NEW_HASH=$(sha256sum CHANGELOG.md | head -c 64) let old_hash = get_hash
if [[ $OLD_HASH != $NEW_HASH ]]; then git-cliff out> "CHANGELOG.md"
git add CHANGELOG.md
git commit -m 'chore(changelog): Update the changelog' if old_hash != get_hash {
echo 'The changes have been added to the changelog file and committed' git add "CHANGELOG.md"
else git commit -m "chore(changelog): Update the changelog"
echo 'No changes have been added to the changelog' print "The changes have been added to the changelog file and committed"
fi } 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. # Releases a new version of n34. Requires a clean file tree with no uncommitted changes.
[script] [script]
release version: release version:
set -e let tag_msg = "Version {{ version }}" + (git-cliff --strip all --unreleased --body '{{ tag_change_body }}')
TAG_MSG="Version {{ version }}$(git-cliff --strip all --unreleased --body '{{ tag_change_body }}')" mut cargo_file = open "Cargo.toml"
sed -i "s/^version\s*= \".*\"/version = \"{{ version }}\"/" ./Cargo.toml
taplo fmt --config ./.taplo.toml ./Cargo.toml $cargo_file.package.version = "{{ version }}"
$cargo_file | save -f "Cargo.toml"
RUST_LOG=none taplo fmt --config "./.taplo.toml"
{{ JUST_EXECUTABLE }} ci {{ JUST_EXECUTABLE }} ci
git-cliff -t "v{{ version }}" > CHANGELOG.md git-cliff -t "v{{ version }}" out> "./CHANGELOG.md"
git add . git add .
git commit -m 'chore: Bump the version to `v{{ version }}`' git commit -m "chore: Bump the version to `v{{ version }}`"
git tag -s -m "$TAG_MSG" "v{{ version }}" git tag -s -m $tag_msg "v{{ version }}"
git push origin master --tags git push origin master --tags
cargo publish cargo publish
# Deploy the book to Github Pages # Deploy the book to Github Pages
[script]
deploy: deploy:
mdbook build --dest-dir {{ BOOK_DEST_DIR }} mdbook build --dest-dir {{ BOOK_DEST_DIR }}
cd {{ BOOK_DEST_DIR }} cd {{ BOOK_DEST_DIR }}
git init . git init .
git checkout -B gh-pages git checkout -B gh-pages
touch .nojekyll touch ".nojekyll"
echo "n34.dev" > CNAME echo "n34.dev" > "CNAME"
git add . git add .
git commit -m "Deploy the book to github pages" git commit -m "Deploy the book to github pages"