From c99b52e8e2bc62008b9999f537a8482bd963da32 Mon Sep 17 00:00:00 2001 From: hfshfg <38004547@qq.com> Date: Sat, 2 May 2026 18:44:40 +0800 Subject: [PATCH] fix(ci): normalize CRLF for .bat/.cmd/.ps1 in portable zip Real bug found in v2.1.0: ubuntu-runner zip preserved LF line endings, which breaks Windows batch parsing. cmd.exe mis-tokenized 'setlocal' as 'local', trashed env vars, and produced 'URL: //node--win-x64.zip' on Node download. Symptom: Windows users who unzip and double-click setup.bat see a flood of 'XXX is not recognized as a command' errors followed by curl 'No host part'. Fix: convert .bat/.cmd/.ps1 to CRLF, ensure .sh/.command/.mjs stay LF, before zipping in the portable-skeleton job. --- .github/workflows/release.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 923e07a..65090d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,6 +32,19 @@ jobs: cp -R portable/. "$stage_dir/" rm -rf "$stage_dir/app" "$stage_dir/data/logs" 2>/dev/null || true + - name: Normalize line endings (CRLF for Windows scripts, LF for shell) + run: | + tag_name="${GITHUB_REF_NAME:-${{ github.event.inputs.tag }}}" + stage_dir="dist/u-claw-portable-${tag_name}" + # Windows batch files MUST be CRLF — cmd.exe mis-parses LF-only files + find "$stage_dir" -type f \( -name '*.bat' -o -name '*.cmd' -o -name '*.ps1' \) -print0 \ + | xargs -0 -I {} sh -c 'sed -i "s/\r$//; s/$/\r/" "{}"' + # Ensure shell scripts stay LF (mac/linux double-click won't run otherwise) + find "$stage_dir" -type f \( -name '*.sh' -o -name '*.command' -o -name '*.mjs' -o -name '*.js' \) -print0 \ + | xargs -0 -I {} sh -c 'sed -i "s/\r$//" "{}"' + # Restore +x on shell entry points + chmod +x "$stage_dir"/*.sh "$stage_dir"/*.command 2>/dev/null || true + - name: Zip skeleton run: | tag_name="${GITHUB_REF_NAME:-${{ github.event.inputs.tag }}}"