【问题标题】:How to update the package.json version using semantic-release/git?如何使用语义发布/git 更新 package.json 版本?
【发布时间】:2022-01-27 00:15:04
【问题描述】:

我想做的事

根据常见问题解答

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

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


我做了什么

  • 为组织 temp 创建一个新的空的私有 Github 存储库,其中包含 README.md.gitignore 用于节点
  • 克隆存储库
  • 通过 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 推送之后。

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

【问题讨论】:

    标签: javascript node.js github npm semantic-release


    【解决方案1】:

    基于这个问题

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

    你还需要 npm 模块。

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

    .

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

    【讨论】:

      猜你喜欢
      • 2022-10-15
      • 1970-01-01
      • 2021-11-18
      • 2021-09-29
      • 2015-05-31
      • 2012-10-15
      • 1970-01-01
      • 1970-01-01
      • 2021-07-06
      相关资源
      最近更新 更多