# @anolilab/semantic-release-preset 中文文档

规范地址：https://npmcn.com/package/%40anolilab/semantic-release-preset/

版本：13\.4\.39
npm 元数据更新时间：2026-11-02T17:16:09.891Z
中文译文更新时间：2026-11-06T05:36:10.252Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40anolilab/semantic-release-preset
原文对照：https://npmcn.com/package/%40anolilab/semantic-release-preset/?lang=original
项目主页：https://github.com/anolilab/semantic-release/tree/main/packages/semantic-release-preset
源码仓库：https://github.com/anolilab/semantic-release

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：90.9 kB，8 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：未声明
- Node.js 要求：^22\.14\.0 \|\| \>=24\.10\.0
- 运行依赖：8 个
- peer 依赖：semantic-release 25\.0\.9，@semantic-release/npm 13\.2\.0，semantic-release-yarn ^3\.0\.2，@anolilab/semantic-release-pnpm 8\.1\.37
- 首次发布：2021-09-02T08:12:51.551Z
- 最新版本发布：2026-11-02T17:16:09.492Z
- 近 30 天下载量：74901（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：131（近 12 个月 53 个）

## 中文简介

语义放出预设.

## 安装

```sh
npm install @anolilab/semantic-release-preset
```

也可以使用：`pnpm add @anolilab/semantic-release-preset`、`yarn add @anolilab/semantic-release-preset`、`bun add @anolilab/semantic-release-preset`

## README

[![semantic-release-preset](https://npmcn.com/package/%40anolilab/semantic-release-preset/__assets__/package-og.svg)](https://github.com/anolilab/semantic-release)

### 语义放出预设.

  

[![typescript-image](https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript)](https://www.typescriptlang.org/) [![mit licence](https://img.shields.io/npm/l/@anolilab/semantic-release-preset?style=for-the-badge)](https://github.com/anolilab/multi-semantic-release/blob/main/LICENSE) [![npm downloads](https://img.shields.io/npm/dm/@anolilab/semantic-release-preset?style=for-the-badge)](https://www.npmjs.com/package/@anolilab/semantic-release-preset) [![Chat](https://img.shields.io/discord/902465130518949899.svg?style=for-the-badge)](https://discord.gg/eajEZvk2PG) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge)](https://github.com/anolilab/multi-semantic-release/blob/main/.github/CONTRIBUTING.md)

* * *

Daniel Bannert的开源工作得到了社区的支持 [GitHub 赞助商](https://github.com/sponsors/prisis)

* * *

可分享 [语义释放](https://github.com/semantic-release/semantic-release) 配置,用于在您的项目中执行一致的 GitHub/ NPM 发布 .

## 目的

-   这种配置还包括一个语义-放行配置,它可以根据您的承诺消息自动GitHub/NPM发布.

## 安装

```bash
npm install --dev-save semantic-release @anolilab/semantic-release-preset
```

```sh
yarn add -D semantic-release @anolilab/semantic-release-preset
```

```sh
pnpm add -D semantic-release @anolilab/semantic-release-preset
```

## 插件

我们使用语义释放生态系统中的以下插件:

-   [@ semmantic-release/changelog (英语)](https://github.com/semantic-release/changelog)
-   [@semantic-release/承诺分析器](https://github.com/semantic-release/commit-analyzer)
-   [@ semmantic-release/执行](https://github.com/semantic-release/exec)
-   [@semantic-release/ git (英语)](https://github.com/semantic-release/git)
-   [@semantic-release/ github (英语)](https://github.com/semantic-release/github)
-   [@ semmantic-release/ npm (英语)](https://github.com/semantic-release/npm) (可选)
-   [@ semetic-release/release-note-generator (英语)](https://github.com/semantic-release/release-notes-generator)
-   [@anolilab/语义化-释放-pnpm](https://github.com/anolilab/semantic-release-pnpm) (可选)
-   [语义 -- -- 释放 -- -- 亚伦](https://github.com/hongaar/semantic-release-yarn) (可选)

## 内容提要

此可共享配置执行以下动作 :

1.  分析承诺[@semantic-release/承诺分析器](https://github.com/semantic-release/commit-analyzer)(中文(简体) )
2.  生成更改日志内容( E)[@ semetic-release/release-note-generator (英语)](https://github.com/semantic-release/release-notes-generator)(中文(简体) )
3.  创建或更新步骤2生成的更改日志文件( S)[@ semmantic-release/changelog (英语)](https://github.com/semantic-release/changelog)(中文(简体) )
4.  将软件包版本更新到下一个发行版本
5.  将资产交给项目的 git 存储器, 并带有承诺信息 core( 释放): ${nextrelease. version} \[skip ci\] ${nextrelease. notes} .
6.  发布 npm 发布方式 :[@ semmantic-release/ npm (英语)](https://github.com/semantic-release/github) 或者说 [@anolilab/语义化-释放-pnpm](https://github.com/anolilab/semantic-release-pnpm) 或者说 [语义 -- -- 释放 -- -- 亚伦](https://github.com/hongaar/semantic-release-yarn)) (可选)
7.  发布一个 GitHub 发布并评论已发布的 Pull Request/ Issues([@semantic-release/ github (英语)](https://github.com/semantic-release/github)(中文(简体) )

## 使用量

当首次安装此软件包时, 以下可共享配置 `.releaserc.json` 自动添加到您的工程文件夹中 :

> 注意: 如果脚本检测到已有的 `.releaserc.json` 文件,它不会覆盖它.

> 说明: 邮局的脚本不运行,你就得加上 `.releaserc.json` 手动.

Npm 发布方式 [@ semmantic-release/ npm (英语)](https://github.com/semantic-release/github)数字 :

```json
{
    "extends": "@anolilab/semantic-release-preset/npm"
}
```

Npm 发布方式 [@anolilab/语义化-释放-pnpm](https://github.com/anolilab/semantic-release-pnpm)数字 :

```json
{
    "extends": "@anolilab/semantic-release-preset/pnpm"
}
```

Npm 发布方式 [语义 -- -- 释放 -- -- 亚伦](https://github.com/hongaar/semantic-release-yarn)数字 :

```json
{
    "extends": "@anolilab/semantic-release-preset/yarn"
}
```

没有 npm 发布 :

```json
{
    "extends": "@anolilab/semantic-release-preset"
}
```

扩展预设的文件内容

```json5
{
    branches: [
        "+([0-9])?(.{+([0-9]),x}).x",
        "main",
        "next",
        "next-major",
        {
            name: "beta",
            prerelease: true,
        },
        {
            name: "alpha",
            prerelease: true,
        },
    ],
    plugins: [
        [
            "@semantic-release/commit-analyzer",
            {
                preset: "conventionalcommits",
            },
        ],
        [
            "@semantic-release/release-notes-generator",
            {
                preset: "conventionalcommits",
            },
        ],
        "@semantic-release/changelog",
        "@semantic-release/npm", // optional
        [
            "@semantic-release/git",
            {
                message: "chore(release): ${nextRelease.gitTag} [skip ci]\n\n${nextRelease.notes}",
            },
        ],
        [
            "@semantic-release/github",
            {
                successComment: false,
                failComment: false,
            },
        ],
    ],
}
```

### 折旧

你想贬低旧版本的套件吗?

选项一是语义-放行-npm-去除-旧版本

#### 安装

```bash
npm install --dev-save semantic-release-npm-deprecate-old-versions
```

```sh
pnpm add -D semantic-release-npm-deprecate-old-versions
```

```sh
yarn add -D semantic-release-npm-deprecate-old-versions
```

没问题,你只要把下面加进去 `.releaserc.json`数字 :

```json
{
    "extends": "@anolilab/semantic-release-preset/npm",
    "plugins": [
        [
            "semantic-release-npm-deprecate-old-versions",
            {
                "rules": [
                    {
                        "rule": "supportLatest",
                        "options": {
                            "numberOfMajorReleases": 1,
                            "numberOfMinorReleases": 1,
                            "numberOfPatchReleases": 1
                        }
                    },
                    {
                        "rule": "supportPreReleaseIfNotReleased",
                        "options": {
                            "numberOfPreReleases": 1
                        }
                    },
                    "deprecateAll"
                ]
            }
        ]
    ]
}
```

找到如何配置插件 [这里](https://github.com/ghusse/semantic-release-npm-deprecate-old-versions)。 。 。 .

选项一是语义解说 -释放 -npm - 解说

#### 安装

```bash
npm install --dev-save semantic-release-npm-deprecate-old-versions
```

```sh
pnpm add -D semantic-release-npm-deprecate-old-versions
```

```sh
yarn add -D semantic-release-npm-deprecate-old-versions
```

没问题,你只要把下面加进去 `.releaserc.json`数字 :

```json
{
    "extends": "@anolilab/semantic-release-preset/npm",
    "plugins": [
        [
            "semantic-release-npm-deprecate",
            {
                "deprecations": [
                    {
                        "version": "< ${nextRelease.version.split('.')[0]}",
                        "message": "Please use ^${nextRelease.version.split('.')[0]}.0.0."
                    }
                ]
            }
        ]
    ]
}
```

找到如何配置插件 [这里](https://www.npmjs.com/package/semantic-release-npm-deprecate)。 。 。 .

## 环境变量配置

确保您的 CI 配置包含以下环境变量 :

-   吉图布: [GitHub 个人访问符](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
    -   当发布新版本时,此插件将尝试承诺并推入所发布的分支. 确保正在运行发行版的用户有按权限并可以绕过分支保护规则.
-   国家防范机制: [Npm 个人访问符](https://www.npmjs.com/package/settings)
    -   国家防范机制标志,这样可以将软件包发布给国家防范机制(一个有额外配置的.npmrc文件也可以被使用)

您可以用干跑来测试您的配置 :

```sh
npx semantic-release --dry-run
```

## GitHub 工作流程

狦琌 [配置 GitHub 工作流程](https://help.github.com/en/articles/configuring-a-workflow) 您可能想要先做一个测试构建矩阵,然后只有在这些测试在所有环境中都成功时才会发布. 接下来的就是,在某件事被合并到 `main`。 。 。 .

以下是运行您测试并发布新版本的新承诺的工作流程配置示例 `main` 分支 :

单语义- 释放实例与纱线, (您也可以使用 pnpm 或 npm )

```yaml
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Semantic Release"

on: # yamllint disable-line rule:truthy
    push:
        branches:
            - "([0-9])?(.{+([0-9]),x}).x"
            - "main"
            - "next"
            - "next-major"
            - "alpha"
            - "beta"

jobs:
    test:
        name: "Semantic Release"

        runs-on: "ubuntu-latest"

        steps:
            - uses: "actions/checkout@v2"
              with:
                  fetch-depth: 0
                  persist-credentials: false
              env:
                  GIT_COMMITTER_NAME: "GitHub Actions Shell"
                  GIT_AUTHOR_NAME: "GitHub Actions Shell"
                  EMAIL: "github-actions[bot]@users.noreply.github.com"

            - name: "Use Node.js 12.x"
              uses: "actions/setup-node@v2"
              with:
                  node-version: "12.x"

            - name: "Get yarn cache directory path"
              id: "yarn-cache-dir-path"
              run: 'echo "::set-output name=dir::$(yarn config get cacheFolder)"'

            - uses: "actions/cache@v2"
              id: "yarn-cache" # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
              with:
                  path: "${{ steps.yarn-cache-dir-path.outputs.dir }}"
                  key: "${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}"
                  restore-keys: |
                      ${{ runner.os }}-yarn-

            - name: "install"
              run: "yarn install --immutable"

            - name: "Build packages"
              run: "yarn build"

            - name: "test"
              run: "yarn run test"

    semantic-release:
        name: "Semantic Release"

        runs-on: "ubuntu-latest"

        needs: ["test"]

        steps:
            - uses: "actions/checkout@v2"
              with:
                  fetch-depth: 0
                  persist-credentials: false
              env:
                  GIT_COMMITTER_NAME: "GitHub Actions Shell"
                  GIT_AUTHOR_NAME: "GitHub Actions Shell"
                  EMAIL: "github-actions[bot]@users.noreply.github.com"

            - name: "Use Node.js 12.x"
              uses: "actions/setup-node@v2"
              with:
                  node-version: "12.x"

            - name: "Get yarn cache directory path"
              id: "yarn-cache-dir-path"
              run: 'echo "::set-output name=dir::$(yarn config get cacheFolder)"'

            - uses: "actions/cache@v2"
              id: "yarn-cache" # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
              with:
                  path: "${{ steps.yarn-cache-dir-path.outputs.dir }}"
                  key: "${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}"
                  restore-keys: |
                      ${{ runner.os }}-yarn-

            - name: "install"
              run: "yarn install --immutable"

            - name: "Build packages"
              if: "success()"
              run: "yarn build"

            - name: "Semantic Release"
              if: "success()"
              env:
                  GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
                  NPM_TOKEN: "${{ secrets.NPM_AUTH_TOKEN }}"
                  GIT_AUTHOR_NAME: "github-actions-shell"
                  GIT_AUTHOR_EMAIL: "github-actions[bot]@users.noreply.github.com"
                  GIT_COMMITTER_NAME: "github-actions-shell"
                  GIT_COMMITTER_EMAIL: "github-actions[bot]@users.noreply.github.com"
              run: "npx semantic-release"
```

要发布多软件包寄存器, 您需要安装 `@anolilab/multi-semantic-release` 财务报告和审定财务报表 `semantic-release`。 。 。 .

多包语义放出以 pnpm 为例

```yaml
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Semantic Release"

on: # yamllint disable-line rule:truthy
    push:
        branches:
            - "([0-9])?(.{+([0-9]),x}).x"
            - "main"
            - "next"
            - "next-major"
            - "alpha"
            - "beta"

# Enable this to use the github packages
# yamllint disable-line rule:comments
#env:
#    package: "@${{ github.repository }}"
#    registry_url: "https://npm.pkg.github.com"
#    scope: "${{ github.repository_owner }}"

jobs:
    test:
        strategy:
            matrix:
                os: ["ubuntu-latest"]
                node_version: ["16", "18", "19", "20"]
            fail-fast: false

        name: "Build & Unit Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"

        runs-on: "${{ matrix.os }}"

        steps:
            - name: "Git checkout"
              uses: "actions/checkout@v3"
              env:
                  GIT_COMMITTER_NAME: "GitHub Actions Shell"
                  GIT_AUTHOR_NAME: "GitHub Actions Shell"
                  EMAIL: "github-actions[bot]@users.noreply.github.com"

            - uses: "pnpm/action-setup@v2.2.4"
              with:
                  version: 8
                  run_install: false

            - name: "Set node version to ${{ matrix.node_version }}"
              uses: "actions/setup-node@v3"
              with:
                  node-version: "${{ matrix.node_version }}"
                  cache: "pnpm"

            - name: "Check npm version"
              run: "npm -v"
              env:
                  SKIP_CHECK: "true"

            - name: "Install packages"
              run: "pnpm install --frozen-lockfile"
              env:
                  SKIP_CHECK: "true"

            # - name: "Build"
            #   run: "pnpm run build:packages"

            # - name: "test and coverage"
            #   run: "pnpm run test:coverage"

    semantic-release:
        name: "Semantic Release"

        runs-on: "ubuntu-latest"

        needs: ["test", "eslint"]

        steps:
            - name: "Git checkout"
              uses: "actions/checkout@v3"
              with:
                  fetch-depth: 0
                  persist-credentials: false
              env:
                  GIT_COMMITTER_NAME: "GitHub Actions Shell"
                  GIT_AUTHOR_NAME: "GitHub Actions Shell"
                  EMAIL: "github-actions[bot]@users.noreply.github.com"

            - uses: "pnpm/action-setup@v2.2.4"
              with:
                  version: 8
                  run_install: false

            - name: "Use Node.js 16.x"
              uses: "actions/setup-node@v3"
              with:
                  node-version: "16.x"
                  cache: "pnpm"

            - name: "Check npm version"
              run: "npm -v"
              env:
                  SKIP_CHECK: "true"

            - name: "Install packages"
              run: "pnpm install --frozen-lockfile"

            # - name: "Build Production"
            #   run: "pnpm run build:prod:packages"

            - name: "npm v8.5+ requires workspaces-update to be set to false"
              run: "echo 'workspaces-update=false' >> .npmrc"

            - name: "Semantic Release"
              if: "success()"
              env:
                  GITHUB_TOKEN: "${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}"
                  NPM_TOKEN: "${{ secrets.NPM_AUTH_TOKEN }}"
                  GIT_AUTHOR_NAME: "github-actions-shell"
                  GIT_AUTHOR_EMAIL: "github-actions[bot]@users.noreply.github.com"
                  GIT_COMMITTER_NAME: "github-actions-shell"
                  GIT_COMMITTER_EMAIL: "github-actions[bot]@users.noreply.github.com"
              run: "pnpm exec multi-semantic-release"

    pnpm-lock-update:
        name: "pnpm-lock.yaml update"

        runs-on: "ubuntu-latest"

        needs: ["semantic-release"]

        steps:
            - name: "Git checkout"
              uses: "actions/checkout@v3"
              with:
                  fetch-depth: 2
              env:
                  GIT_COMMITTER_NAME: "GitHub Actions Shell"
                  GIT_AUTHOR_NAME: "GitHub Actions Shell"
                  EMAIL: "github-actions[bot]@users.noreply.github.com"

            - uses: "pnpm/action-setup@v2.2.4"
              with:
                  version: 8

            - name: "Use Node.js 16.x"
              uses: "actions/setup-node@v3"
              with:
                  node-version: "16.x"

            - name: "Update pnpm lock"
              run: "pnpm install --no-frozen-lockfile"

            - name: "Commit modified files"
              uses: "stefanzweifel/git-auto-commit-action@v4.16.0"
              with:
                  commit_message: "chore: updated pnpm-lock.yaml"
                  commit_author: "prisis <d.bannert@anolilab.de>"
                  commit_user_email: "d.bannert@anolilab.de"
                  commit_user_name: "prisis"
                  branch: "${{ github.head_ref }}"
```

## 关于 GitHub 保护分支的说明

如果你要释放一个 [GitHub 保护分支](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches) 您需要更改 git 承诺给所有者/ 管理员, 并允许 repo 管理员绕过分支保护( 确保分支保护规则中禁用“ 包含管理员 ” )

如果你的Repo属于一个组织,你可以创建一个bot账户,并在repo上赋予它管理权. 如果你的Repo在个人帐户下,你没有选择让Repo所有者成为释放的罪犯.

无论是哪种方式,你都要为承诺者账户创建一个GitHub个人访问符并赋予其"repo"访问权限. 然后把它放到您的 GitHub 仓库里的 GH Token 秘密中 .

> 注意: GitHub 不与叉子分享秘密并拉动请求.

## 支持的节点.js版本

这一生态系统中的图书馆尽最大努力追踪 [Node.js的释放时间表](https://nodejs.org/en/about/releases/)。这里 [(单位:千美元) 贴上我们为什么认为 这很重要](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a)。 。 。 .

## 捐款

如果你愿意帮忙看看 [问题清单](https://github.com/anolilab/javascript-style-guide/issues) 看看我们 [捐款](https://npmcn.com/package/%40anolilab/semantic-release-preset/.github/CONTRIBUTING.md) 盾.

> **说明:** 请注意,该项目已连同《协助者行为守则》一起公布。 通过参加这个项目,你同意遵守其条款.

## 贷项

-   [丹尼尔·班纳特](https://github.com/prisis)
-   [所有贡献者](https://github.com/anolilab/javascript-style-guide/graphs/contributors)

## 在阿诺利拉布制造的

这是一个开源项目,将永远可以自由使用。 如果你觉得这很酷,请 显示它. [阿诺利拉布](https://www.anolilab.com/open-source) 是一个开发与AI工作室。 联系我们 [你好@anolilab.com](mailto:hello@anolilab.com) 如果你需要任何帮助 这些技术 或者只是想打个招呼!

## 许可证

Anolilab语义 -- -- 释放 -- -- 预设是开源软件,根据 [麻省理工学院](https://npmcn.com/package/%40anolilab/semantic-release-preset/LICENSE.md)

## 常见问题

### @anolilab/semantic-release-preset 是什么？

语义放出预设\.

### 如何安装 @anolilab/semantic-release-preset？

在项目目录运行 npm install @anolilab/semantic-release-preset，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：semantic-release（25\.0\.9）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @anolilab/semantic-release-preset 支持 TypeScript 吗？

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

### @anolilab/semantic-release-preset 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @anolilab/semantic-release-preset 需要什么版本的 Node\.js？

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

### @anolilab/semantic-release-preset 可以商用吗？

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

### @anolilab/semantic-release-preset 的下载量有多少？

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

### @anolilab/semantic-release-preset 还在维护吗？

最新版本 13\.4\.39 发布于 2026/11/03（3 天前）；至今共发布 131 个版本，其中过去 12 个月发布了 53 个；首次发布于 2021/09/02。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

