@@ -147,13 +147,6 @@ jobs:
147147 git sparse-checkout set --no-cone '/*' '!/.repos/'
148148 git -c checkout.workers=0 checkout --detach FETCH_HEAD
149149
150- - name : Setup Vite+
151- uses : voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1
152- with :
153- node-version-file : package.json
154- cache : true
155- run-install : false
156-
157150 # pnpm checks the lockfile and policy before reusing this result. A missing
158151 # artifact leaves the cache empty, so installation runs the checks again.
159152 - name : Download dependency verification
@@ -163,10 +156,35 @@ jobs:
163156 name : release-dependency-verification
164157 path : ${{ runner.temp }}/pnpm-metadata
165158
166- - name : Install desktop dependencies
159+ - name : Setup dependencies
160+ uses : ./.github/actions/setup-ci-deps
161+ with :
162+ install-args : --filter=@t3tools/desktop... --filter=t3... --filter=@t3tools/scripts...
167163 env :
168164 pnpm_config_cache_dir : ${{ runner.temp }}/pnpm-metadata
169- run : vp install --filter=@t3tools/desktop... --filter=t3... --filter=@t3tools/scripts...
165+
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"
170188
171189 - name : Cache resource monitor
172190 id : resource_monitor_cache
@@ -258,6 +276,63 @@ jobs:
258276 if [[ "${{ inputs.version }}" =~ -nightly\.[0-9]{8}\.[0-9]+$ ]]; then brand=nightly; fi
259277 node scripts/apply-web-brand-assets.ts "$brand" apps/server/dist/client
260278
279+ - name : Resolve target Node.js for the CLI executable
280+ id : target_node
281+ if : inputs.cli_archive && inputs.platform == 'win'
282+ shell : bash
283+ run : echo "version=$(node -p 'require("./package.json").engines.node')" >> "$GITHUB_OUTPUT"
284+
285+ # The download only changes with engines.node, so a cached copy keeps
286+ # releases off nodejs.org, which stalls on the runners some days.
287+ - name : Restore target Node.js for the CLI executable
288+ id : target_node_cache
289+ if : inputs.cli_archive && inputs.platform == 'win'
290+ uses : actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
291+ with :
292+ path : ${{ runner.temp }}/node-download
293+ key : node-download-v${{ steps.target_node.outputs.version }}-win-${{ inputs.arch }}
294+
295+ # tsdown downloads the target Node with one fetch and no retry, and
296+ # nodejs.org drops that download often enough to fail releases. Seed
297+ # tsdown's cache with a retried, checksum-verified copy instead. A transfer
298+ # under 100 KB/s for 30s counts as failed, so a stall retries.
299+ - name : Download target Node.js for the CLI executable
300+ if : inputs.cli_archive && inputs.platform == 'win' && steps.target_node_cache.outputs.cache-hit != 'true'
301+ shell : bash
302+ env :
303+ VERSION : ${{ steps.target_node.outputs.version }}
304+ run : |
305+ set -euo pipefail
306+ name="node-v$VERSION-win-${{ inputs.arch }}"
307+ dir="$RUNNER_TEMP/node-download"
308+ mkdir -p "$dir"
309+ fetch=(curl -fsSL --retry 5 --retry-all-errors --connect-timeout 10 --speed-limit 102400 --speed-time 30)
310+ "${fetch[@]}" -o "$dir/$name.zip" "https://nodejs.org/dist/v$VERSION/$name.zip"
311+ "${fetch[@]}" -o "$dir/SHASUMS256.txt" "https://nodejs.org/dist/v$VERSION/SHASUMS256.txt"
312+ (cd "$dir" && grep " $name.zip\$" SHASUMS256.txt | sha256sum -c -)
313+
314+ # Saved right away so a later failure in this job still keeps the download.
315+ - name : Save target Node.js for the CLI executable
316+ if : inputs.cli_archive && inputs.platform == 'win' && steps.target_node_cache.outputs.cache-hit != 'true'
317+ uses : actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
318+ with :
319+ path : ${{ runner.temp }}/node-download
320+ key : ${{ steps.target_node_cache.outputs.cache-primary-key }}
321+
322+ - name : Install target Node.js for the CLI executable
323+ if : inputs.cli_archive && inputs.platform == 'win'
324+ shell : bash
325+ env :
326+ VERSION : ${{ steps.target_node.outputs.version }}
327+ run : |
328+ set -euo pipefail
329+ name="node-v$VERSION-win-${{ inputs.arch }}"
330+ dir="$RUNNER_TEMP/node-download"
331+ dest="${XDG_CACHE_HOME:-$HOME/.cache}/tsdown/node/v$VERSION/win-${{ inputs.arch }}"
332+ mkdir -p "$dest"
333+ (cd "$dir" && grep " $name.zip\$" SHASUMS256.txt | sha256sum -c -)
334+ unzip -p "$dir/$name.zip" "$name/node.exe" > "$dest/node.exe"
335+
261336 # Setup Vite+ selects the exact engines.node version from package.json.
262337 # Native builds embed that executable; cross-target builds download the
263338 # same version for their target.
@@ -318,6 +393,9 @@ jobs:
318393 if : inputs.cli_archive
319394 shell : bash
320395 env :
396+ pnpm_config_cache_dir : ${{ steps.stage_pnpm.outputs.dir }}/cache
397+ pnpm_config_store_dir : ${{ steps.stage_pnpm.outputs.dir }}/store
398+ pnpm_config_prefer_offline : " true"
321399 APPLE_API_KEY : ${{ secrets.APPLE_API_KEY }}
322400 APPLE_API_KEY_ID : ${{ secrets.APPLE_API_KEY_ID }}
323401 APPLE_API_ISSUER : ${{ secrets.APPLE_API_ISSUER }}
@@ -437,7 +515,10 @@ jobs:
437515 - name : Build desktop artifact
438516 shell : bash
439517 env :
440- pnpm_config_cache_dir : ${{ runner.temp }}/pnpm-metadata
518+ # pnpm only goes to the registry for packages or versions the cache lacks.
519+ pnpm_config_cache_dir : ${{ steps.stage_pnpm.outputs.dir }}/cache
520+ pnpm_config_store_dir : ${{ steps.stage_pnpm.outputs.dir }}/store
521+ pnpm_config_prefer_offline : " true"
441522 T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR : true
442523 T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS : ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
443524 CSC_LINK : ${{ secrets.CSC_LINK }}
@@ -522,6 +603,23 @@ jobs:
522603
523604 vp run dist:desktop:artifact "${args[@]}"
524605
606+ # Warm installs only touch the store index, so new content means a fetch.
607+ - name : Check staged install cache for new content
608+ id : stage_pnpm_changed
609+ shell : bash
610+ run : |
611+ dir="${{ steps.stage_pnpm.outputs.dir }}"
612+ 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 ' ')
613+ echo "Staged installs added $new cached files."
614+ echo "changed=$([[ "$new" -gt 0 ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
615+
616+ - name : Save staged install cache
617+ if : steps.stage_pnpm_changed.outputs.changed == 'true'
618+ uses : actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
619+ with :
620+ path : ${{ steps.stage_pnpm.outputs.dir }}
621+ key : ${{ steps.stage_pnpm_cache.outputs.cache-primary-key }}
622+
525623 # A build can package fine and still not open (a missing module in the
526624 # backend or the bundle). This launches the app from the shipped
527625 # AppImage or DMG.
0 commit comments