Skip to content

Commit 78d7999

Browse files
CI: Make webpack cache key dynamic by Node major and drop build.mjs hash
- Export Node major to GITHUB_ENV for use in cache key - Avoid hardcoding node20 in cache key; use node${env.NODE_MAJOR} - Remove build.mjs from cache key; rely on webpack buildDependencies invalidation This keeps cache keys portable across Node upgrades while avoiding unnecessary cache misses. Webpack will invalidate restored caches when build.mjs changes via buildDependencies.
1 parent 29b332b commit 78d7999

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.github/workflows/pre-release-build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
- uses: actions/setup-node@v4
2525
with:
2626
node-version: 20
27+
- name: Detect Node major version
28+
run: echo "NODE_MAJOR=$(node -p 'process.versions.node.split(".")[0]')" >> $GITHUB_ENV
2729
- name: Cache npm cache
2830
uses: actions/cache@v4
2931
with:
@@ -38,9 +40,9 @@ jobs:
3840
path: |
3941
.cache/webpack
4042
node_modules/.cache/webpack
41-
key: ${{ runner.os }}-node20-webpack-${{ hashFiles('build.mjs') }}-${{ hashFiles('**/package-lock.json') }}
43+
key: ${{ runner.os }}-node${{ env.NODE_MAJOR }}-webpack-${{ hashFiles('**/package-lock.json') }}
4244
restore-keys: |
43-
${{ runner.os }}-node20-webpack-
45+
${{ runner.os }}-node${{ env.NODE_MAJOR }}-webpack-
4446
- run: npm run build
4547

4648
- uses: josStorer/get-current-time@v2

0 commit comments

Comments
 (0)