From f5710f9685e39ba36347c54adada6310986d66dd Mon Sep 17 00:00:00 2001 From: dawsbot <3408480+dawsbot@users.noreply.github.com> Date: Thu, 18 Jun 2026 14:28:17 -0600 Subject: [PATCH] Add `nr --version`; bump release actions off deprecated Node 20 - `nr --version` / `nr -V` print the version (from CARGO_PKG_VERSION, so it tracks the release automatically) and work outside a project. - Bump actions/checkout, actions/upload-artifact and actions/download-artifact v4 -> v5 in the Release workflow; the v4 line runs on Node 20, which GitHub now forces onto Node 24 with a deprecation warning. v5 targets Node 24 natively. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/release.yml | 6 +++--- src/main.rs | 10 ++++++++++ test.sh | 11 +++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b3aaa5..e8625ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Install Rust uses: dtolnay/rust-toolchain@stable @@ -64,7 +64,7 @@ jobs: cd ../../.. - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: ${{ matrix.name }} path: ${{ matrix.name }}.* @@ -73,7 +73,7 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v5 with: path: artifacts diff --git a/src/main.rs b/src/main.rs index febdc49..fb38646 100644 --- a/src/main.rs +++ b/src/main.rs @@ -188,6 +188,16 @@ fn run_exec(argv: &[String], dir: &Path, extra_args: &[OsString]) -> ! { fn main() { let args: Vec = env::args_os().skip(1).collect(); + // `--version` works anywhere, even outside a project, so handle it before + // looking for tasks. + if matches!( + args.first().and_then(|a| a.to_str()), + Some("--version" | "-V") + ) { + println!("nr {}", env!("CARGO_PKG_VERSION")); + return; + } + let detection = match sources::detect() { Some(d) => d, None => { diff --git a/test.sh b/test.sh index 8cd9314..a673212 100755 --- a/test.sh +++ b/test.sh @@ -362,6 +362,17 @@ else echo "(skipping uv equivalence test: uv not installed)" fi +# Test 24: --version / -V print the version, and work outside a project +VER_TMP=$(mktemp -d) +OUTPUT=$(cd "$VER_TMP" && "$BIN_ABS" --version 2>&1) +OUTPUT_SHORT=$(cd "$VER_TMP" && "$BIN_ABS" -V 2>&1) +rmdir "$VER_TMP" +if echo "$OUTPUT" | grep -qE '^nr [0-9]+\.[0-9]+\.[0-9]+' && [ "$OUTPUT" = "$OUTPUT_SHORT" ]; then + pass "--version prints version ($OUTPUT)" +else + fail "--version prints version: '$OUTPUT' / '$OUTPUT_SHORT'" +fi + echo "" echo "Results: ${PASS} passed, ${FAIL} failed"