Skip to content

Commit d9237f4

Browse files
t3dotggclaude
andcommitted
ci(release): desktop builds stop hitting the npm registry for staged installs
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent eb751fa commit d9237f4

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

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

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,29 @@ jobs:
163163
env:
164164
pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
165165

166+
# The CLI archive and the staged app install without a lockfile, so they
167+
# ask the registry about every package and fetch platform packages the
168+
# workspace store lacks. They share this registry metadata and store. A
169+
# new week starts cold, which bounds how stale cached ranges can get.
170+
- name: Resolve staged install cache
171+
id: stage_pnpm
172+
shell: bash
173+
run: |
174+
echo "dir=$RUNNER_TEMP/desktop-stage-pnpm" >> "$GITHUB_OUTPUT"
175+
echo "prefix=desktop-stage-pnpm-v2-${{ inputs.platform }}-${{ inputs.arch }}-$(date -u +%G-%V)-" >> "$GITHUB_OUTPUT"
176+
177+
- name: Restore staged install cache
178+
id: stage_pnpm_cache
179+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
180+
with:
181+
path: ${{ steps.stage_pnpm.outputs.dir }}
182+
key: ${{ steps.stage_pnpm.outputs.prefix }}${{ github.run_id }}-${{ github.run_attempt }}
183+
restore-keys: ${{ steps.stage_pnpm.outputs.prefix }}
184+
185+
- name: Mark staged install cache
186+
shell: bash
187+
run: mkdir -p "${{ steps.stage_pnpm.outputs.dir }}" && touch "$RUNNER_TEMP/desktop-stage-pnpm.marker"
188+
166189
- name: Cache resource monitor
167190
id: resource_monitor_cache
168191
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
@@ -371,6 +394,9 @@ jobs:
371394
if: inputs.cli_archive
372395
shell: bash
373396
env:
397+
pnpm_config_cache_dir: ${{ steps.stage_pnpm.outputs.dir }}/cache
398+
pnpm_config_store_dir: ${{ steps.stage_pnpm.outputs.dir }}/store
399+
pnpm_config_prefer_offline: "true"
374400
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
375401
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
376402
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
@@ -490,7 +516,10 @@ jobs:
490516
- name: Build desktop artifact
491517
shell: bash
492518
env:
493-
pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
519+
# pnpm only goes to the registry for packages or versions the cache lacks.
520+
pnpm_config_cache_dir: ${{ steps.stage_pnpm.outputs.dir }}/cache
521+
pnpm_config_store_dir: ${{ steps.stage_pnpm.outputs.dir }}/store
522+
pnpm_config_prefer_offline: "true"
494523
T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: true
495524
T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS: ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
496525
CSC_LINK: ${{ secrets.CSC_LINK }}
@@ -575,6 +604,23 @@ jobs:
575604
576605
vp run dist:desktop:artifact "${args[@]}"
577606
607+
# Warm installs only touch the store index, so new content means a fetch.
608+
- name: Check staged install cache for new content
609+
id: stage_pnpm_changed
610+
shell: bash
611+
run: |
612+
dir="${{ steps.stage_pnpm.outputs.dir }}"
613+
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 ' ')
614+
echo "Staged installs added $new cached files."
615+
echo "changed=$([[ "$new" -gt 0 ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
616+
617+
- name: Save staged install cache
618+
if: steps.stage_pnpm_changed.outputs.changed == 'true'
619+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
620+
with:
621+
path: ${{ steps.stage_pnpm.outputs.dir }}
622+
key: ${{ steps.stage_pnpm_cache.outputs.cache-primary-key }}
623+
578624
# A build can package fine and still not open (a missing module in the
579625
# backend or the bundle). This launches the app from the shipped
580626
# AppImage or DMG.

0 commit comments

Comments
 (0)