From 2a7c953c62a07642e40dd04e33bf981c9e88ffc5 Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 16 Jul 2024 17:41:04 +0800 Subject: [PATCH] chore: adjust release pr workflow (#6044) * chore: adjust workflow and add publish doc --------- Co-authored-by: antv --- .../workflows/{release.yml => publish.yml} | 12 ++++--- .github/workflows/release-pr.yml | 27 -------------- .github/workflows/version.yml | 35 ------------------- PUBLISH.md | 19 ++++++++++ package.json | 11 +++--- turbo.json | 3 +- 6 files changed, 34 insertions(+), 73 deletions(-) rename .github/workflows/{release.yml => publish.yml} (62%) delete mode 100644 .github/workflows/release-pr.yml delete mode 100644 .github/workflows/version.yml create mode 100644 PUBLISH.md diff --git a/.github/workflows/release.yml b/.github/workflows/publish.yml similarity index 62% rename from .github/workflows/release.yml rename to .github/workflows/publish.yml index fdb0bca4221..575cca8dd32 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/publish.yml @@ -1,5 +1,6 @@ -# 合并 release 分支到 v5 分支时自动发布到 npm -name: Auto Release +# 当具有 publish 标签的 PR 被合并时,自动发布新版本 +# Automatically publish a new version when a PR with the publish label is merged +name: Auto Publish on: pull_request: types: [closed] @@ -7,9 +8,9 @@ on: - v5 jobs: - release: + publish: runs-on: ubuntu-latest - if: github.event.pull_request.head.ref == 'release' && github.event.pull_request.merged == true + if: contains(github.event.pull_request.labels.*.name, 'publish') && github.event.pull_request.merged == true steps: - uses: actions/checkout@v3 @@ -23,8 +24,9 @@ jobs: uses: pnpm/action-setup@v4 with: version: 9 + run_install: true - - name: Release + - name: Publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml deleted file mode 100644 index 31893d0c8d3..00000000000 --- a/.github/workflows/release-pr.yml +++ /dev/null @@ -1,27 +0,0 @@ -# 创建发布分支和 PR / Create release branch and PR -name: Create release PR - -on: - workflow_dispatch: - -jobs: - create_release_pr: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Create release branch - run: | - git checkout -b release - git add . - git commit -m "Update for automated release PR" || true - git push --set-upstream origin release - - - name: Create PR - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - base: v5 - title: '[Bot] Automated PR from release to v5' - body: 'This PR was created automatically by GitHub Actions.' diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml deleted file mode 100644 index 391a68af5ac..00000000000 --- a/.github/workflows/version.yml +++ /dev/null @@ -1,35 +0,0 @@ -# 自动更新版本号 / Auto Update Version -name: Auto Update Version -on: - push: - branches: - - release - -jobs: - version: - name: Update Package Version - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - - name: Install pnpm and dependencies - uses: pnpm/action-setup@v4 - with: - version: 9 - - - name: Update Version - run: | - cd ./packages/g6 - npm run version - - - name: Create Release Pull Request - uses: changesets/action@v1 - with: - commit: 'chore(release): update version' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/PUBLISH.md b/PUBLISH.md new file mode 100644 index 00000000000..88dd7e1bd8f --- /dev/null +++ b/PUBLISH.md @@ -0,0 +1,19 @@ +This project uses changeset to manage version release, and the specific release process is as follows: + +1. Complete related development work +2. Create a branch from v5 (any name you want) +3. Run `pnpm changeset` and fill in the information as prompted +4. run `pnpm run version` to generate the version number +5. Merge the branch into the v5 branch by creating a PR on GitHub and adding a `publish` tag +6. When a branch is merged, GitHub Actions are automatically triggered and published to npm + +--- + +本项目通过 changeset 来管理版本发布,具体的发布流程如下: + +1. 完成相关的开发工作 +2. 从 v5 分支创建一个分支(任意分支名均可) +3. 执行 `pnpm changeset` 命令,根据提示填写相关信息 +4. 执行 `pnpm run version` 命令,生成版本号 +5. 在 GitHub 上创建一个 PR,并添加 `publish` 标签,将该分支合并到 v5 分支 +6. 分支合并后,会自动触发 GitHub Actions,发布到 npm \ No newline at end of file diff --git a/package.json b/package.json index 1043a06157d..e7d878a0384 100644 --- a/package.json +++ b/package.json @@ -3,15 +3,16 @@ "private": true, "repository": "https://github.com/antvis/G6.git", "scripts": { - "site": "pnpm -r --stream --filter=./packages/site run dev", - "watch": "pnpm -r --stream --filter=!./site run start", - "postinstall": "husky install", - "prepare": "husky install", "build": "turbo build --filter=!@antv/g6-site", "ci": "turbo run ci --filter=!@antv/g6-site", "contribute": "node ./scripts/contribute.mjs", + "postinstall": "husky install", + "prepare": "husky install", "publish": "pnpm publish -r --publish-branch v5", - "release": "changeset release" + "release": "changeset release", + "site": "pnpm -r --stream --filter=./packages/site run dev", + "version": "changeset version && turbo version", + "watch": "pnpm -r --stream --filter=!./site run start" }, "commitlint": { "extends": [ diff --git a/turbo.json b/turbo.json index b61d2fd32c5..cb6a31521da 100644 --- a/turbo.json +++ b/turbo.json @@ -7,6 +7,7 @@ }, "ci": { "dependsOn": ["^ci"] - } + }, + "version": {} } }