@adfinis-sygroup/semantic-release-config 中文文档教程

发布于 3年前 浏览 4 项目主页 更新于 3年前

npm version

@adfinis-sygroup/semantic-release-config

语义发布的可共享配置。

Features

目前,此配置只是对默认配置稍作修改:

  • Add @semantic-release/git plugin to publish updated package.json and CHANGELOG.md to repository after deployment

Installation

安装 npm 包

yarn add --dev @adfinis-sygroup/semantic-release-config

并将以下内容添加到 extends 属性。 io/semantic-release/usage/configuration#configuration-file">语义发布配置

{
  "extends": "@adfinis-sygroup/semantic-release-config"
}

这个 repo 还包含 commitlint一个>。 通过将以下内容添加到 package.json,对其进行配置以检查提交消息的格式是否符合常规提交格式

  "commitlint": {
    "extends": [
      "@commitlint/config-conventional"
    ]
  }

设置一个预提交钩子来集成它; 例如,通过安装 husky:

yarn add husky --dev

然后将以下内容添加到 package.json:

{
  "scripts": {
    "prepare": "husky install"
  }
}

并添加以下脚本(使用执行权限)到 .husky/pre-commit

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# skip in CI
[ -n "$CI" ] && exit 0

# lint commit message
yarn commitlint --edit $1

CI Configuration

  • Add credentials for GitHub and npm as described here
  • Run semantic-release in the deploy stage as described here

发布 Github 工作流程示例:

name: Release

on: workflow_dispatch

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/setup-node@v2

      - name: Install dependencies
        run: yarn install

      - name: Release on NPM
        run: yarn semantic-release
        env:
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Commitizen

您还可以选择设置 commitizen 以一种更具交互性的方式添加提交:

$ git cz

? Select the type of change that you're committing:
? What is the scope of this change (e.g. component or file name)?
? Write a short, imperative tense description of the change:
? Provide a longer description of the change: (press enter to skip)
? Are there any breaking changes? No
? Does this change affect any open issues? No

设置很简单:

npm install -g commitizen
commitizen init cz-conventional-changelog --yarn --dev --exact

之后,运行 git cz 而不是 git commit

npm version

@adfinis-sygroup/semantic-release-config

Sharable configuration for semantic release.

Features

Currently, this config is only a slight modification of the default config:

  • Add @semantic-release/git plugin to publish updated package.json and CHANGELOG.md to repository after deployment

Installation

Install the npm package

yarn add --dev @adfinis-sygroup/semantic-release-config

and add the following to the extends property of your semantic release configuration:

{
  "extends": "@adfinis-sygroup/semantic-release-config"
}

This repo also contains commitlint. Configure it to check that commit messagesas are formatted according to the conventional commit format by adding the following to package.json:

  "commitlint": {
    "extends": [
      "@commitlint/config-conventional"
    ]
  }

Set up a pre-commit hook to integrate it; e.g. by installing husky:

yarn add husky --dev

then adding the following to package.json:

{
  "scripts": {
    "prepare": "husky install"
  }
}

and adding the following script (with execute permissions) to .husky/pre-commit:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# skip in CI
[ -n "$CI" ] && exit 0

# lint commit message
yarn commitlint --edit $1

CI Configuration

  • Add credentials for GitHub and npm as described here
  • Run semantic-release in the deploy stage as described here

Example for a release Github workflow:

name: Release

on: workflow_dispatch

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/setup-node@v2

      - name: Install dependencies
        run: yarn install

      - name: Release on NPM
        run: yarn semantic-release
        env:
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Commitizen

Optionally, you can also set up commitizen for a more interactive way of adding commits:

$ git cz

? Select the type of change that you're committing:
? What is the scope of this change (e.g. component or file name)?
? Write a short, imperative tense description of the change:
? Provide a longer description of the change: (press enter to skip)
? Are there any breaking changes? No
? Does this change affect any open issues? No

Setup is simple:

npm install -g commitizen
commitizen init cz-conventional-changelog --yarn --dev --exact

After, run git cz instead of git commit.

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文