Skip to content

Commit 07f7f97

Browse files
t3dotggclaude
andauthored
ci(release): releases stop depending on npm and nodejs.org when nothing changed (#26362)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent c677d5f commit 07f7f97

2 files changed

Lines changed: 66 additions & 7 deletions

File tree

‎.github/actions/setup-ci-deps/action.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ runs:
7070
INSTALL_ARGS: ${{ inputs.install-args }}
7171
run: |
7272
echo "path=$(vp pm cache dir)" >> "$GITHUB_OUTPUT"
73+
metadata_dir="${pnpm_config_cache_dir:-$RUNNER_TEMP/pnpm-metadata}"
74+
echo "pnpm_config_cache_dir=$metadata_dir" >> "$GITHUB_ENV"
75+
echo "verified=$metadata_dir/lockfile-verified.jsonl" >> "$GITHUB_OUTPUT"
7376
if [[ -z "$INSTALL_ARGS" ]]; then
7477
echo "namespace=full" >> "$GITHUB_OUTPUT"
7578
else
@@ -94,6 +97,16 @@ runs:
9497
pnpm-${{ steps.pnpm_store.outputs.namespace }}-v1-${{ runner.os }}-${{ runner.arch }}-
9598
pnpm-full-v1-${{ runner.os }}-${{ runner.arch }}-
9699
100+
# pnpm accepts an earlier pass for the same lockfile and policy at any age, so
101+
# a cached record skips fetching registry metadata for every package.
102+
- name: Restore lockfile verification
103+
id: pnpm_verified
104+
if: inputs.install == 'true'
105+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
106+
with:
107+
path: ${{ steps.pnpm_store.outputs.verified }}
108+
key: pnpm-verified-v1-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json') }}
109+
97110
- name: Install dependencies
98111
if: inputs.install == 'true'
99112
shell: bash
@@ -102,6 +115,13 @@ runs:
102115
# Unquoted so each filter is its own argument.
103116
run: vp install $INSTALL_ARGS
104117

118+
- name: Save lockfile verification
119+
if: inputs.install == 'true' && steps.pnpm_verified.outputs.cache-hit != 'true'
120+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
121+
with:
122+
path: ${{ steps.pnpm_store.outputs.verified }}
123+
key: ${{ steps.pnpm_verified.outputs.cache-primary-key }}
124+
105125
# A filtered install that started from the current full store adds nothing
106126
# worth a second copy of it.
107127
- name: Save pnpm store

‎.github/workflows/release-desktop.yml‎

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)