@continuous-auth/semantic-release-npm

中文文档
4.0.0发布于 2023/10/31MITES Module近 30 天下载 3033

semantic-release plugin to publish a npm package

原始使用文档
文档目录9 节
  1. Install
  2. Usage
  3. Configuration
  4. npm registry authentication
  5. npm provenance
  6. Environment variables
  7. Options
  8. npm configuration
  9. Examples

@continuous-auth/semantic-release-npm

semantic-release plugin to publish a npm package using CFA for 2FA codes.

npm latest version npm next version

StepDescription
verifyConditionsVerify the presence of the NPM_TOKEN environment variable, or an .npmrc file, and verify the authentication method is valid.
prepareUpdate the package.json version and create the npm package tarball.
addChannelAdd a release to a dist-tag.
publishPublish the npm package to the registry.

Install

$ npm install @continuous-auth/semantic-release-npm -D

Usage

The plugin can be configured in the semantic-release configuration file:

{
  "plugins": ["@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", "@continuous-auth/semantic-release-npm"]
}

Configuration

npm registry authentication

The npm token authentication configuration is required and can be set via environment variables.

Automation tokens are recommended since they can be used for an automated workflow, even when your account is configured to use the auth-and-writes level of 2FA.

npm provenance

If you are publishing to the official registry and your pipeline is on a provider that is supported by npm for provenance, npm can be configured to publish with provenance.

Since semantic-release wraps the npm publish command, configuring provenance is not exposed directly. Instead, provenance can be configured through the other configuration options exposed by npm. Provenance applies specifically to publishing, so our recommendation is to configure under publishConfig within the package.json.

npm provenance on GitHub Actions

For package provenance to be signed on the GitHub Actions CI the following permission is required to be enabled on the job:

permissions:
  id-token: write # to enable use of OIDC for npm provenance

It's worth noting that if you are using semantic-release to its fullest with a GitHub release, GitHub comments, and other features, then more permissions are required to be enabled on this job:

permissions:
  contents: write # to be able to publish a GitHub release
  issues: write # to be able to comment on released issues
  pull-requests: write # to be able to comment on released pull requests
  id-token: write # to enable use of OIDC for npm provenance

Refer to the GitHub Actions recipe for npm package provenance for the full CI job's YAML code example.

Environment variables

VariableDescription
NPM_TOKENNpm token created via npm token create
CFA_PROJECT_IDProject ID on CFA
CFA_SECRETSecret configured on CFA for this repository

Options

OptionsDescriptionDefault
npmPublishWhether to publish the npm package to the registry. If false the package.json version will still be updated.false if the package.json private property is true, true otherwise.
pkgRootDirectory path to publish..
tarballDirDirectory path in which to write the package tarball. If false the tarball is not be kept on the file system.false

Note: The pkgRoot directory must contain a package.json. The version will be updated only in the package.json and npm-shrinkwrap.json within the pkgRoot directory.

Note: If you use a shareable configuration that defines one of these options you can set it to false in your semantic-release configuration in order to use the default value.

npm configuration

The plugin uses the npm CLI which will read the configuration from .npmrc. See npm config for the option list.

The registry can be configured via the npm environment variable NPM_CONFIG_REGISTRY and will take precedence over the configuration in .npmrc.

The registry and dist-tag can be configured under publishConfig in the package.json:

{
  "publishConfig": {
    "registry": "https://registry.npmjs.org/",
    "tag": "latest"
  }
}

Notes:

  • The presence of an .npmrc file will override any specified environment variables.
  • The presence of registry or dist-tag under publishConfig in the package.json will take precedence over the configuration in .npmrc and NPM_CONFIG_REGISTRY

Examples

The npmPublish and tarballDir option can be used to skip the publishing to the npm registry and instead, release the package tarball with another plugin. For example with the @semantic-release/github plugin:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "@continuous-auth/semantic-release-npm",
      {
        "npmPublish": false,
        "tarballDir": "dist"
      }
    ],
    [
      "@semantic-release/github",
      {
        "assets": "dist/*.tgz"
      }
    ]
  ]
}

When publishing from a sub-directory with the pkgRoot option, the package.json and npm-shrinkwrap.json updated with the new version can be moved to another directory with a postversion. For example with the @semantic-release/git plugin:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "@continuous-auth/semantic-release-npm",
      {
        "pkgRoot": "dist"
      }
    ],
    [
      "@semantic-release/git",
      {
        "assets": ["package.json", "npm-shrinkwrap.json"]
      }
    ]
  ]
}
{
  "scripts": {
    "postversion": "cp -r package.json .. && cp -r npm-shrinkwrap.json .."
  }
}

版本与发布记录

@continuous-auth/semantic-release-npm 共发布 4 个版本,首次发布于 2019/04/27;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.0.0latest2023/10/313 年前
3.0.02022/09/224 年前
2.0.0next2019/07/257 年前
1.0.32019/04/277 年前

关于 @continuous-auth/semantic-release-npm 的常见问题

@continuous-auth/semantic-release-npm 是什么?

semantic-release plugin to publish a npm package

如何安装 @continuous-auth/semantic-release-npm?

在项目目录运行 npm install @continuous-auth/semantic-release-npm,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:semantic-release(>=20.1.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@continuous-auth/semantic-release-npm 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/continuous-auth__semantic-release-npm 是否存在。

@continuous-auth/semantic-release-npm 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@continuous-auth/semantic-release-npm 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^18.17 || >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@continuous-auth/semantic-release-npm 可以商用吗?

@continuous-auth/semantic-release-npm 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@continuous-auth/semantic-release-npm 的下载量有多少?

根据 npm 官方下载统计,@continuous-auth/semantic-release-npm 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,033 次,日均约 101 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@continuous-auth/semantic-release-npm 还在维护吗?

最新版本 4.0.0 发布于 2023/10/31(3 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/04/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。