4

我想做的事

基于常见问题解答

https://semantic-release.gitbook.io/semantic-release/support/faq#why-is-the-package.jsons-version-not-updated-in-my-repository

我想在新版本上更新 package.json 版本号。


我做了什么

  • temp为具有README.md.gitignore节点的组织创建一个新的空私有 Github 存储库
  • 克隆存储库
  • 通过 git 修复第一条提交消息rebase -i --root并将其更改为feat: initial commit
  • 使用内容创建一个 package.json
{
  "name": "temp",
  "version": "0.0.0-development",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/my-organization/temp.git"
  }
}
  • 设置语义释放
npm install semantic-release -D
npm install @semantic-release/git -D
npm install @semantic-release/changelog -D
  • 创建一个.releaserc.json
{
    "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/release-notes-generator",
      "@semantic-release/changelog",
      "@semantic-release/git"
    ]
}
  • 创建一个新的 Github 工作流release.yml
name: Release on push on main branch

on:
  push:
    branches:
      - main

jobs:
  release-on-push-on-main-branch:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: 16.x

      - name: Install dependencies
        run: npm install

      - name: Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: npx semantic-release --branches main
  • 使用消息提交所有内容feat: next commit
  • 强制推到原点

问题

package.json文件不会被语义发布机器人更新。即使在修改README.md文件并使用feat: this should trigger a new release.

图片

我如何告诉语义发布推送新的包版本?

4

1 回答 1

5

基于这个问题

https://github.com/semantic-release/semantic-release/issues/1593

你还需要 npm 模块。

  • npm install @semantic-release/npm -D
  • "private": true,如果您不想发布到 npm,请添加到您的 package.json
  • 将 npm 插件添加到发布配置文件(顺序很重要)

.

{
    "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/release-notes-generator",
      "@semantic-release/changelog",
      "@semantic-release/npm",
      "@semantic-release/git"
    ]
}
于 2021-12-29T12:28:41.403 回答