语义发布不会更新我的 Angular 库的 package.json

semantic-release does not update package.json of my Angular library

我已将此 Angular 库上传到我在 Gitlab 上创建的包注册表。我已经能够使用 CI 将我的图书馆成功上传到这个注册表。我现在想对该库实施语义版本控制,但我不太清楚该怎么做……我的库版本似乎没有更新。这是我当前的 Gitlab CI 配置:

default:
  image: node:16
  before_script:
    - npm ci --cache node_modules --prefer-offline
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - node_modules/

stages:
  - build
  - semver-check
  - deploy

build:
  only:
    - main
  stage: build
  script:
    - npm install
    - npm run build-lib
  artifacts:
    paths:
      - dist/

semver-check:
  stage: semver-check
  only:
    refs:
    - main
    - alpha
    - /^(([0-9]+)\.)?([0-9]+)\.x/
    - /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
  script:
    - cd $CI_PROJECT_DIR/dist/my-compiled-lib
    - cat package.json
    - npm install @semantic-release/gitlab
    - npx semantic-release
    - cat package.json

deploy:
  only:
    - main
  stage: deploy
  script:
    - cd $CI_PROJECT_DIR/dist/my-compiled-lib
    - cat package.json
    - echo "@my-group:registry https://${CI_SERVER_HOST}/api/v4/packages/npm/">.npmrc
    - echo "//${CI_SERVER_HOST}/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}">>.npmrc
    - echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}">>.npmrc
    - npm publish
  dependencies:
    - build

图书馆package.json

{
  "name": "@my-group/angular-lib",
  "version": "1.0.6",
  "publishConfig": {
    "@my-group:registry": "https://gitlab.com/api/v4/projects/XXXXXXX/packages/npm/"
  },
  "scripts": {
    "build-lib": "ng build lib-angular",
    "semantic-release": "semantic-release"
  },
  "peerDependencies": {
    "@angular/cdk": "^13.0.0",
    "@angular/common": "^13.1.0",
    "@angular/core": "^13.1.0",
    "@angular/material": "^13.2.0",
    "ngx-bootstrap": "^8.0.0",
    "rxjs": "~7.4.0"
  },
  "dependencies": {
    "tslib": "^2.3.0"
  },
  "devDependencies": {
    "@semantic-release/gitlab": "^7.0.4",
    "semantic-release": "^19.0.2"
  }
}

.releaserc.yml

{
  "branches": ["main"],
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "@semantic-release/gitlab",
      {
        "gitlabUrl": "https://gitlab.com",
        "gitlabApiPathPrefix": "/api/v4",
        "verifyConditions": []
      }
    ],
    ["@semantic-release/npm", {
      "npmPublish": false,
      "tarballDir": "dist"
    }],
    [
      "@semantic-release/git",
      {
        "assets": ["dist/my-compiled-lib/package.json"],
        "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ]
  ]
}

问题是我没有通过提交消息触发发布。解决后,package.json 正常更新。