Release built from a shared cache
A tag-triggered npm publish restores the npm cache.
The release job restores the npm cache with cache: npm. Every CI run on the default branch can save to that cache, so a compromised dependency or action in an ordinary build can plant files that end up in the published package. Since June 2026 runs that outsiders can set off, such as pull_request_target and issue_comment, only restore caches unless a job sets cache-mode: write, which narrows the risk without removing it.
Release and publish workflows should build without restoring caches.
# Publishes the package to npm when a version tag is pushed. The build restores# the npm cache, which every CI run on the default branch can write to.name: Release on: push: tags: ["v*"] permissions: contents: read id-token: write jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 cache: npm registry-url: https://registry.npmjs.org - run: npm ci - run: npm publish --provenance env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}