一键导入
npm-trusted-publishing
Set up or debug npm Trusted Publishing (OIDC) from GitHub Actions. Handles permissions, metadata validation, and provenance.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Set up or debug npm Trusted Publishing (OIDC) from GitHub Actions. Handles permissions, metadata validation, and provenance.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Extract distilled page content as Markdown using Chromium's on-device ML page content annotation.
Fetch a URL using Playwright and convert its content to Markdown.
Run a Google Search and capture the AI response/Overview.
Gerrit helpers for fetching unresolved comments and CL diffs.
Paul's modern stack conventions for new projects (pnpm, native node test, esbuild, buildless-types). Consult when starting a new project or repository.
How to effectively use QMD (Quick Markdown Search) to pull in extra relevant context, run multi-query searches, extract high-scoring chunk IDs, and fetch their contents. Use this skill when asked to search across a large markdown knowledge base, run QMD queries, or retrieve deep context using the qmd CLI.
| name | npm-trusted-publishing |
| description | Set up or debug npm Trusted Publishing (OIDC) from GitHub Actions. Handles permissions, metadata validation, and provenance. |
Configure and debug secure, tokenless npm publishing from GitHub Actions using OpenID Connect (OIDC) and Provenance.
Trusted Publishing eliminates the need for long-lived NPM_TOKEN secrets by using short-lived, cryptographically-signed tokens.
The workflow MUST grant id-token: write permissions to fetch the OIDC token. This can be declared globally at the top level of the file or inside the target job block.
permissions:
id-token: write # Required for OIDC provenance authentication
contents: read # Required for repository checkout
Trusted Publishing with provenance requires a modern Node.js environment (v20+) and npm v9.5.0+. Using standard runner defaults or .nvmrc configurations works reliably.
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/* # npm v11.5.1+ (Node v24+) is required for Trusted Publishing
registry-url: 'https://registry.npmjs.org'
NPM validates provenance against the repository field.
.git Suffix & git+ Prefix are OPTIONAL: You can use the raw HTTPS URL (e.g. https://github.com/USER/REPO) or the git-specific URL (e.g. git+https://github.com/USER/REPO.git). Most modern npm/node setups handle these automatically. However, OIDC matching can sometimes be sensitive to normalization; if OIDC fails, try toggling these formats.{
"repository": {
"type": "git",
"url": "git+https://github.com/USER/REPO.git"
}
}
A standard reference template is provided inside this skill folder at references/publish.yml for drop-in integration.
Use standard publish flags to enable provenance.
- name: Publish to npm
run: npm publish --provenance --access public --registry https://registry.npmjs.org/
version property in package.json is strictly bumped to a new, unreleased semver identifier prior to workflow execution.workflow_dispatch (rather than an authentic git push) generates an OIDC token payload where ref and sha environment claims diverge from standard annotated publication tags. The npm pre-authorization gateway routinely drops these customized dynamic event scopes.git tag v1.0.0 && git push origin v1.0.0).'packagename@1.4.12' is not in this registry) because npm cannot authorize the publish without a pre-configured relationship.npm login then npm publish --access public).--registry https://registry.npmjs.org/ in the publish command. Ensure no .npmrc is overriding the registry to a mirror or private proxy.404 Not Found (instead of 403 Forbidden) when the OIDC token claims do not match any configured Trusted Publisher for the package, or if Trusted Publishing has not been configured yet for this package.so-fancy for so-fancy/diff-so-fancy) and is case-sensitive.publish.yml) match exactly.repository.url format in package.json. In some cases, the git+ prefix or missing .git extension can cause validation mismatches, even if the npm CLI claims to auto-correct/normalize it.git+https://github.com/owner/repo.git (official format) to avoid normalization warnings.https://github.com/owner/repo.git (without git+ but with .git) as some users have reported this resolves OIDC claim mismatches.repository.url in package.json is missing or doesn't match the GitHub URL).package.json against the actual repository URL.npmjs.com or has an "Environment" mismatch.publish.yml) are exact.jobs.publish.environment: release.The skill includes a validation script to check your local configuration:
node <path-to-skill>/scripts/validate.mjs <path-to-package.json>
It verifies:
.git suffix on repository.url.id-token: write permission.registry-url configurations in setup-node.lts/* or 24+) for robust OIDC support.When setting up a new project, provide these instructions to the user in strict sequential order:
.github/workflows/publish.yml file to your remote GitHub repository before initializing the trusted publisher mapping on npmjs.com. Configuring the dashboard mapping while the upstream repository lacks the workflow script can cause preliminary token evaluation handshakes to cache invalid target structures, resulting in unresolvable 400 Bad Request authorization drops during deployment runs.npm login
npm publish --access public
YOUR_USERNAME (or your npm organization name)YOUR_REPOpublish.ymlNPM_TOKEN is NO LONGER REQUIRED in GitHub Secrets.For more detailed information, consult the official documentation. It is often helpful to fetch this URL to verify the latest field requirements or troubleshooting steps: https://docs.npmjs.org/trusted-publishers