Skip to content
TypeScript

ci(release): releases stop depending on npm and nodejs.org when nothing changed (#26362)

Theo Browne07f7f976097b
diff --git a/.github/actions/setup-ci-deps/action.yml b/.github/actions/setup-ci-deps/action.yml
index e97365e2f3e..e9b7ae70a36 100644
--- a/.github/actions/setup-ci-deps/action.yml
+++ b/.github/actions/setup-ci-deps/action.yml
@@ -70,6 +70,9 @@ runs:
INSTALL_ARGS: ${{ inputs.install-args }}
run: |
echo "path=$(vp pm cache dir)" >> "$GITHUB_OUTPUT"
+ metadata_dir="${pnpm_config_cache_dir:-$RUNNER_TEMP/pnpm-metadata}"
+ echo "pnpm_config_cache_dir=$metadata_dir" >> "$GITHUB_ENV"
+ echo "verified=$metadata_dir/lockfile-verified.jsonl" >> "$GITHUB_OUTPUT"
if [[ -z "$INSTALL_ARGS" ]]; then
echo "namespace=full" >> "$GITHUB_OUTPUT"
else
@@ -94,6 +97,16 @@ runs:
pnpm-${{ steps.pnpm_store.outputs.namespace }}-v1-${{ runner.os }}-${{ runner.arch }}-
pnpm-full-v1-${{ runner.os }}-${{ runner.arch }}-
+ # pnpm accepts an earlier pass for the same lockfile and policy at any age, so
+ # a cached record skips fetching registry metadata for every package.
+ - name: Restore lockfile verification
+ id: pnpm_verified
+ if: inputs.install == 'true'
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
+ with:
+ path: ${{ steps.pnpm_store.outputs.verified }}
+ key: pnpm-verified-v1-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json') }}
+
- name: Install dependencies
if: inputs.install == 'true'
shell: bash
@@ -102,6 +115,13 @@ runs:
# Unquoted so each filter is its own argument.
run: vp install $INSTALL_ARGS
+ - name: Save lockfile verification
+ if: inputs.install == 'true' && steps.pnpm_verified.outputs.cache-hit != 'true'
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
+ with:
+ path: ${{ steps.pnpm_store.outputs.verified }}
+ key: ${{ steps.pnpm_verified.outputs.cache-primary-key }}
+
# A filtered install that started from the current full store adds nothing
# worth a second copy of it.
- name: Save pnpm store
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 3383bb0e80b..359070e5482 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -254,21 +254,60 @@ jobs:
if [[ "${{ inputs.version }}" =~ -nightly\.[0-9]{8}\.[0-9]+$ ]]; then brand=nightly; fi
node scripts/apply-web-brand-assets.ts "$brand" apps/server/dist/client
+ - name: Resolve target Node.js for the CLI executable
+ id: target_node
+ if: inputs.cli_archive && inputs.platform == 'win'
+ shell: bash
+ run: echo "version=$(node -p 'require("./package.json").engines.node')" >> "$GITHUB_OUTPUT"
+
+ # The download only changes with engines.node, so a cached copy keeps
+ # releases off nodejs.org, which stalls on the runners some days.
+ - name: Restore target Node.js for the CLI executable
+ id: target_node_cache
+ if: inputs.cli_archive && inputs.platform == 'win'
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
+ with:
+ path: ${{ runner.temp }}/node-download
+ key: node-download-v${{ steps.target_node.outputs.version }}-win-${{ inputs.arch }}
+
# tsdown downloads the target Node with one fetch and no retry, and
# nodejs.org drops that download often enough to fail releases. Seed
- # tsdown's cache with a retried, checksum-verified copy instead.
+ # tsdown's cache with a retried, checksum-verified copy instead. A transfer
+ # under 100 KB/s for 30s counts as failed, so a stall retries.
- name: Download target Node.js for the CLI executable
+ if: inputs.cli_archive && inputs.platform == 'win' && steps.target_node_cache.outputs.cache-hit != 'true'
+ shell: bash
+ env:
+ VERSION: ${{ steps.target_node.outputs.version }}
+ run: |
+ set -euo pipefail
+ name="node-v$VERSION-win-${{ inputs.arch }}"
+ dir="$RUNNER_TEMP/node-download"
+ mkdir -p "$dir"
+ fetch=(curl -fsSL --retry 5 --retry-all-errors --connect-timeout 10 --speed-limit 102400 --speed-time 30)
+ "${fetch[@]}" -o "$dir/$name.zip" "https://nodejs.org/dist/v$VERSION/$name.zip"
+ "${fetch[@]}" -o "$dir/SHASUMS256.txt" "https://nodejs.org/dist/v$VERSION/SHASUMS256.txt"
+ (cd "$dir" && grep " $name.zip\$" SHASUMS256.txt | sha256sum -c -)
+
+ # Saved right away so a later failure in this job still keeps the download.
+ - name: Save target Node.js for the CLI executable
+ if: inputs.cli_archive && inputs.platform == 'win' && steps.target_node_cache.outputs.cache-hit != 'true'
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
+ with:
+ path: ${{ runner.temp }}/node-download
+ key: ${{ steps.target_node_cache.outputs.cache-primary-key }}
+
+ - name: Install target Node.js for the CLI executable
if: inputs.cli_archive && inputs.platform == 'win'
shell: bash
+ env:
+ VERSION: ${{ steps.target_node.outputs.version }}
run: |
set -euo pipefail
- version="$(node -p 'require("./package.json").engines.node')"
- name="node-v$version-win-${{ inputs.arch }}"
- dest="${XDG_CACHE_HOME:-$HOME/.cache}/tsdown/node/v$version/win-${{ inputs.arch }}"
+ name="node-v$VERSION-win-${{ inputs.arch }}"
dir="$RUNNER_TEMP/node-download"
- mkdir -p "$dir" "$dest"
- curl -fsSL --retry 5 --retry-all-errors -o "$dir/$name.zip" "https://nodejs.org/dist/v$version/$name.zip"
- curl -fsSL --retry 5 --retry-all-errors -o "$dir/SHASUMS256.txt" "https://nodejs.org/dist/v$version/SHASUMS256.txt"
+ dest="${XDG_CACHE_HOME:-$HOME/.cache}/tsdown/node/v$VERSION/win-${{ inputs.arch }}"
+ mkdir -p "$dest"
(cd "$dir" && grep " $name.zip\$" SHASUMS256.txt | sha256sum -c -)
unzip -p "$dir/$name.zip" "$name/node.exe" > "$dest/node.exe"