github项目 规范 提交和 持续集成

安装 commitlint 



npm install --save-dev @commitlint/{cli,config-conventional}
echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js



npm install --save-dev husky


{
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  }
}

安装 commitizen 规范提交工具

npm install --save-dev commitizen

# 在项目文件夹运行
npx commitizen init cz-conventional-changelog --save-dev --save-exact

安装 standard-version (控制版本,CHANGELOG)

npm i --save-dev standard-version

# npm run script
npm run release -- --prerelease

npm run release -- --prerelease alpha

# npm run script  (major, minor or patch)
npm run release -- --release-as minor
# Or
npm run release -- --release-as 1.1.0


安装github release 工具

npm install -D conventional-github-releaser

npm script 脚本

{
  "scripts": {
    "cz": "git cz",
    "release": "standard-version",
    "github-release": "conventional-github-releaser -p angular"
  }
}

GitActions CI

# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
  push:
    tags: 
      - 'v*'
  pull_request:
    branches: [master]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: npm ci
      - run: npm test

  publish-npm:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/
      - run: npm ci
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
      - run: npm run github-release
        env:
          CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}}

  storybook:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - name: Install dependencies
        run: npm ci
      - run: npm run deploy-storybook -- --ci
        env:
          GH_TOKEN: ${{github.ACTOR}}:${{secrets.GITHUB_TOKEN}}
      

操作步骤

# 开发

# 提交代码
npm run cz



# 打包集成时候

# 第一次
npm run release -- --first-release

npm run release
git push --follow-tags origin master

 

你可能感兴趣的:(js)