Skip to content

Commit

Permalink
feat: 构建自动化发包流程
Browse files Browse the repository at this point in the history
  • Loading branch information
mengqiuleo committed Nov 4, 2024
1 parent bc65b04 commit 757b985
Show file tree
Hide file tree
Showing 12 changed files with 825 additions and 35 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
16 changes: 16 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@changesets/changelog-github",
{
"repo": "mengqiuleo/axios-plugin"
}
],
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# https://docs.github.com/en/actions/using-workflows/about-workflows
# 整个工作流的名称
name: Release

# 监听 main 分支的 push 事件(有更新时)
on:
push:
branches:
- main

# 所有的 jobs
jobs:
# 定义一个名为 release 的 job
release:
# 指定运行所需要的虚拟机环境(必填)
runs-on: ubuntu-latest
# 定义步骤
steps:
# https://github.com/actions/checkout
# 拉取代码
- name: Checkout Repo
uses: actions/checkout@v2

# https://github.com/actions/setup-node
# 安装 node
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x

# https://github.com/pnpm/action-setup
# 安装 pnpm
- name: Setup Pnpm
uses: pnpm/action-setup@v2
with:
version: 9.x

# https://pnpm.io/zh/cli/install#--frozen-lockfile
# 如果缓存没有命中,安装依赖
- name: Install dependencies
run: pnpm install --no-frozen-lockfile --ignore-scripts

# https://github.com/changesets/action
# 自动创建发布 PR 和 发布 npm
- name: Create Release Pull Request or Publish to npm
uses: changesets/action@v1
# 参数配置
with:
publish: pnpm release
version: pnpm change:version
commit: 'chore: version packages'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"devDependencies": {
"@babel/core": "^7.22.1",
"@babel/preset-env": "^7.22.2",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.9",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@types/jest": "^29.5.1",
"axios": "^1.7.7",
"axios-mock-adapter": "^1.21.4",
Expand All @@ -19,7 +22,6 @@
"rollup": "^3.23.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.34.1",
"ts-jest": "^29.1.0",
"ts-morph": "^24.0.0",
Expand All @@ -30,6 +32,10 @@
"test": "jest --bail",
"prepare": "husky install",
"build": "node scripts/build.js",
"change": "changeset add",
"change:version": "changeset version",
"release": "pnpm build && pnpm release:only",
"release:only": "changeset publish",
"gen-doc": "node scripts/generateApiDoc.js"
},
"husky": {
Expand Down
7 changes: 7 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @axios-plugin/core

## 1.0.0

### Major Changes

- refactor all packages
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axios-plugin/core",
"version": "0.1.0",
"version": "1.0.0",
"description": "@axios-plugin/core 是 @axios-plugin 的核心,它可以让 axios 成为基于插件的请求库",
"main": "src/index.ts",
"module": "src/index.ts",
Expand Down
12 changes: 12 additions & 0 deletions packages/retry/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @axios-plugin/retry

## 1.0.0

### Major Changes

- refactor all packages

### Patch Changes

- Updated dependencies []:
- @axios-plugin/core@1.0.0
2 changes: 1 addition & 1 deletion packages/retry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axios-plugin/retry",
"version": "0.1.0",
"version": "1.0.0",
"description": "拦截失败的请求并在可能的情况下进行重试",
"author": "mengqiuleo",
"homepage": "https://github.com/mengqiuleo/axios-plugin#README",
Expand Down
12 changes: 12 additions & 0 deletions packages/throttle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @axios-plugin/throttle

## 1.0.0

### Major Changes

- refactor all packages

### Patch Changes

- Updated dependencies []:
- @axios-plugin/core@1.0.0
2 changes: 1 addition & 1 deletion packages/throttle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axios-plugin/throttle",
"version": "0.1.0",
"version": "1.0.0",
"description": "限制 axios 发送请求的频率",
"author": "mengqiuleo",
"homepage": "https://github.com/mengqiuleo/axios-plugin#README",
Expand Down
Loading

0 comments on commit 757b985

Please sign in to comment.