@@ -254,21 +254,60 @@ jobs:
254254 if [[ "${{ inputs.version }}" =~ -nightly\.[0-9]{8}\.[0-9]+$ ]]; then brand=nightly; fi
255255 node scripts/apply-web-brand-assets.ts "$brand" apps/server/dist/client
256256
257+ - name : Resolve target Node.js for the CLI executable
258+ id : target_node
259+ if : inputs.cli_archive && inputs.platform == 'win'
260+ shell : bash
261+ run : echo "version=$(node -p 'require("./package.json").engines.node')" >> "$GITHUB_OUTPUT"
262+
263+ # The download only changes with engines.node, so a cached copy keeps
264+ # releases off nodejs.org, which stalls on the runners some days.
265+ - name : Restore target Node.js for the CLI executable
266+ id : target_node_cache
267+ if : inputs.cli_archive && inputs.platform == 'win'
268+ uses : actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
269+ with :
270+ path : ${{ runner.temp }}/node-download
271+ key : node-download-v${{ steps.target_node.outputs.version }}-win-${{ inputs.arch }}
272+
257273 # tsdown downloads the target Node with one fetch and no retry, and
258274 # nodejs.org drops that download often enough to fail releases. Seed
259- # tsdown's cache with a retried, checksum-verified copy instead.
275+ # tsdown's cache with a retried, checksum-verified copy instead. A transfer
276+ # under 100 KB/s for 30s counts as failed, so a stall retries.
260277 - name : Download target Node.js for the CLI executable
278+ if : inputs.cli_archive && inputs.platform == 'win' && steps.target_node_cache.outputs.cache-hit != 'true'
279+ shell : bash
280+ env :
281+ VERSION : ${{ steps.target_node.outputs.version }}
282+ run : |
283+ set -euo pipefail
284+ name="node-v$VERSION-win-${{ inputs.arch }}"
285+ dir="$RUNNER_TEMP/node-download"
286+ mkdir -p "$dir"
287+ fetch=(curl -fsSL --retry 5 --retry-all-errors --connect-timeout 10 --speed-limit 102400 --speed-time 30)
288+ "${fetch[@]}" -o "$dir/$name.zip" "https://nodejs.org/dist/v$VERSION/$name.zip"
289+ "${fetch[@]}" -o "$dir/SHASUMS256.txt" "https://nodejs.org/dist/v$VERSION/SHASUMS256.txt"
290+ (cd "$dir" && grep " $name.zip\$" SHASUMS256.txt | sha256sum -c -)
291+
292+ # Saved right away so a later failure in this job still keeps the download.
293+ - name : Save target Node.js for the CLI executable
294+ if : inputs.cli_archive && inputs.platform == 'win' && steps.target_node_cache.outputs.cache-hit != 'true'
295+ uses : actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
296+ with :
297+ path : ${{ runner.temp }}/node-download
298+ key : ${{ steps.target_node_cache.outputs.cache-primary-key }}
299+
300+ - name : Install target Node.js for the CLI executable
261301 if : inputs.cli_archive && inputs.platform == 'win'
262302 shell : bash
303+ env :
304+ VERSION : ${{ steps.target_node.outputs.version }}
263305 run : |
264306 set -euo pipefail
265- version="$(node -p 'require("./package.json").engines.node')"
266- name="node-v$version-win-${{ inputs.arch }}"
267- dest="${XDG_CACHE_HOME:-$HOME/.cache}/tsdown/node/v$version/win-${{ inputs.arch }}"
307+ name="node-v$VERSION-win-${{ inputs.arch }}"
268308 dir="$RUNNER_TEMP/node-download"
269- mkdir -p "$dir" "$dest"
270- curl -fsSL --retry 5 --retry-all-errors -o "$dir/$name.zip" "https://nodejs.org/dist/v$version/$name.zip"
271- curl -fsSL --retry 5 --retry-all-errors -o "$dir/SHASUMS256.txt" "https://nodejs.org/dist/v$version/SHASUMS256.txt"
309+ dest="${XDG_CACHE_HOME:-$HOME/.cache}/tsdown/node/v$VERSION/win-${{ inputs.arch }}"
310+ mkdir -p "$dest"
272311 (cd "$dir" && grep " $name.zip\$" SHASUMS256.txt | sha256sum -c -)
273312 unzip -p "$dir/$name.zip" "$name/node.exe" > "$dest/node.exe"
274313
0 commit comments