diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e20eb7f..829477c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,13 +5,6 @@ on: push: branches: - main - # paths: - # - src/** - pull_request: - branches: - - main - # paths: - # - src/** # 任务 jobs: @@ -25,7 +18,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: 16.14.x + node-version: 18.12.x registry-url: 'https://registry.npmjs.org' cache: 'npm' @@ -33,13 +26,15 @@ jobs: - run: npm ci # lint check - - run: npm run lint + # - run: npm run lint # 这条命令包含了测试和上传覆盖率 - - run: npm run coveralls + # - run: npm run coveralls # 打包发布 - run: npm run build --if-present - - run: npm publish + - name: Release + run: npm run release env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_ALOVA_PUBLISH_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index c8207ad..fa81019 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,9 @@ "build:umd": "cross-env NODE_ENV=development rollup -c ./config/rollup.config.umd.js", "build:umd.min": "cross-env NODE_ENV=production rollup -c ./config/rollup.config.umd.js", "build": "npm run clean && npm run build:esm && npm run build:umd && npm run build:umd.min", - "release": "npm publish", - "coveralls": "npm run test:coverage && coveralls < coverage/lcov.info" + "release": "semantic-release --branches main", + "coveralls": "npm run test:coverage && coveralls < coverage/lcov.info", + "commit": "git add . && git-cz && git push" }, "publishConfig": { "access": "public" @@ -64,8 +65,10 @@ "alova": "^2.0.4", "axios": "^1.3.4", "babel-jest": "^29.2.2", + "commitizen": "^4.3.0", "coveralls": "^3.1.1", "cross-env": "5.2.0", + "cz-conventional-changelog": "^3.3.0", "eslint": "^8.35.0", "eslint-config-prettier": "^8.6.0", "eslint-plugin-prettier": "^4.2.1", @@ -79,11 +82,17 @@ "rollup": "^2.74.1", "rollup-plugin-terser": "^7.0.2", "rollup-plugin-typescript2": "^0.31.2", + "semantic-release": "^21.0.1", "ts-jest": "^29.0.3", "ts-jest-mock-import-meta": "^1.0.0", "ts-node": "^10.9.1", "tslib": "^2.4.0", "typescript": "^4.7.2", "vue": "^3.2.47" + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } } }