Skip to content
TypeScript

ci(release): desktop builds stop hitting the npm registry for staged installs (#26458)

Theo Browne6bc87b94e15c
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 359070e5482..ba40c4fb89c 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -163,6 +163,29 @@ jobs:
env:
pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
+ # The CLI archive and the staged app install without a lockfile, so they
+ # ask the registry about every package and fetch platform packages the
+ # workspace store lacks. They share this registry metadata and store. A
+ # new week starts cold, which bounds how stale cached ranges can get.
+ - name: Resolve staged install cache
+ id: stage_pnpm
+ shell: bash
+ run: |
+ echo "dir=$RUNNER_TEMP/desktop-stage-pnpm" >> "$GITHUB_OUTPUT"
+ echo "prefix=desktop-stage-pnpm-v2-${{ inputs.platform }}-${{ inputs.arch }}-$(date -u +%G-%V)-" >> "$GITHUB_OUTPUT"
+
+ - name: Restore staged install cache
+ id: stage_pnpm_cache
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
+ with:
+ path: ${{ steps.stage_pnpm.outputs.dir }}
+ key: ${{ steps.stage_pnpm.outputs.prefix }}${{ github.run_id }}-${{ github.run_attempt }}
+ restore-keys: ${{ steps.stage_pnpm.outputs.prefix }}
+
+ - name: Mark staged install cache
+ shell: bash
+ run: mkdir -p "${{ steps.stage_pnpm.outputs.dir }}" && touch "$RUNNER_TEMP/desktop-stage-pnpm.marker"
+
- name: Cache resource monitor
id: resource_monitor_cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
@@ -371,6 +394,9 @@ jobs:
if: inputs.cli_archive
shell: bash
env:
+ pnpm_config_cache_dir: ${{ steps.stage_pnpm.outputs.dir }}/cache
+ pnpm_config_store_dir: ${{ steps.stage_pnpm.outputs.dir }}/store
+ pnpm_config_prefer_offline: "true"
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
@@ -490,7 +516,10 @@ jobs:
- name: Build desktop artifact
shell: bash
env:
- pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
+ # pnpm only goes to the registry for packages or versions the cache lacks.
+ pnpm_config_cache_dir: ${{ steps.stage_pnpm.outputs.dir }}/cache
+ pnpm_config_store_dir: ${{ steps.stage_pnpm.outputs.dir }}/store
+ pnpm_config_prefer_offline: "true"
T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: true
T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS: ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
CSC_LINK: ${{ secrets.CSC_LINK }}
@@ -575,6 +604,23 @@ jobs:
vp run dist:desktop:artifact "${args[@]}"
+ # Warm installs only touch the store index, so new content means a fetch.
+ - name: Check staged install cache for new content
+ id: stage_pnpm_changed
+ shell: bash
+ run: |
+ dir="${{ steps.stage_pnpm.outputs.dir }}"
+ new=$(find "$dir/cache/v12" "$dir/store/v11/files" -type f -newer "$RUNNER_TEMP/desktop-stage-pnpm.marker" 2>/dev/null | wc -l | tr -d ' ')
+ echo "Staged installs added $new cached files."
+ echo "changed=$([[ "$new" -gt 0 ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
+
+ - name: Save staged install cache
+ if: steps.stage_pnpm_changed.outputs.changed == 'true'
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
+ with:
+ path: ${{ steps.stage_pnpm.outputs.dir }}
+ key: ${{ steps.stage_pnpm_cache.outputs.cache-primary-key }}
+
# A build can package fine and still not open (a missing module in the
# backend or the bundle). This launches the app from the shipped
# AppImage or DMG.