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.
This commit is contained in:
hfshfg
2026-05-02 18:44:40 +08:00
parent 5916ff5158
commit c99b52e8e2

View File

@@ -32,6 +32,19 @@ jobs:
cp -R portable/. "$stage_dir/" cp -R portable/. "$stage_dir/"
rm -rf "$stage_dir/app" "$stage_dir/data/logs" 2>/dev/null || true 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 - name: Zip skeleton
run: | run: |
tag_name="${GITHUB_REF_NAME:-${{ github.event.inputs.tag }}}" tag_name="${GITHUB_REF_NAME:-${{ github.event.inputs.tag }}}"