From 267261c45b1c178baa93db44db4a8f86e4588a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Fri, 25 Oct 2024 10:16:24 +0800 Subject: [PATCH 1/5] ci: add Auto Release --- .github/workflows/auto-release.yml | 96 ++++++++++++++++++++++++++++++ .github/workflows/tag-push.yml | 24 ++++++++ 2 files changed, 120 insertions(+) create mode 100644 .github/workflows/auto-release.yml create mode 100644 .github/workflows/tag-push.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 00000000..84215f5b --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,96 @@ +name: Auto Release + +on: + pull_request: + branches: [develop] + types: [opened, synchronize, reopened, closed] + paths: + - package.json + issue_comment: + types: [edited] + +jobs: + generator: + runs-on: ubuntu-latest + if: > + github.event_name == 'pull_request' && + github.event.pull_request.merged == false && + startsWith(github.head_ref, 'release/') + steps: + - run: echo "The head of this PR starts with 'release/'" + - uses: actions/checkout@v4 + - uses: TDesignOteam/tdesign-tag-action@main + id: tag-action + with: + token: ${{ secrets.GITHUB_TOKEN }} + - uses: TDesignOteam/tdesign-changelog-action@main + id: changelog + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag: ${{ steps.tag-action.outputs.version }} + - name: Add comment + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + ${{ steps.changelog.outputs.changelog }} + comment_add_log: + runs-on: ubuntu-latest + if: > + github.event_name == 'issue_comment' + && github.event.issue.pull_request + && github.event.sender.login == github.event.issue.user.login + && startsWith(github.event.comment.body, '## 🌈 ') + steps: + - id: comment + shell: bash + run: | + result=$(curl ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}") + headrefreg='"ref": "(release/[[:digit:]]{1,2}\.[[:digit:]]{1,2}\.[[:digit:]]{1,2})",' + if [[ $result =~ $headrefreg ]] + then + echo "属于 release pr 的 comment ${BASH_REMATCH[1]}" + else + echo "不属于 release pr 的 comment" && exit 1 + fi + echo "::set-output name=branch::${BASH_REMATCH[1]}" + # zsh $match[1] + - uses: actions/checkout@v4 + with: + ref: ${{ steps.comment.outputs.branch }} + - name: Commit and push if needed + env: + BODY: ${{ github.event.comment.body }} + run: | + txt=$(cat CHANGELOG.md) + echo "${txt%%##*}$BODY${txt##*---}" > CHANGELOG.md + git add . + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -m "chore: changelog's changes" + git push + echo "💾 pushed changelog's changes" + merge_tag: + runs-on: ubuntu-latest + if: > + github.event_name == 'pull_request' && + github.event.pull_request.merged == true && + startsWith(github.head_ref, 'release/') + steps: + - uses: actions/checkout@v4 + with: + ref: develop + token: ${{ secrets.PERSONAL_TOKEN }} + - uses: TDesignOteam/tdesign-tag-action@main + id: tag-action + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: tag and push if needed + run: | + echo "${{ steps.tag-action.outputs.version }}" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git tag ${{ steps.tag-action.outputs.version }} + git push origin ${{ steps.tag-action.outputs.version }} + echo "pushed tag ${{ steps.tag-action.outputs.version }}" diff --git a/.github/workflows/tag-push.yml b/.github/workflows/tag-push.yml new file mode 100644 index 00000000..064d55e5 --- /dev/null +++ b/.github/workflows/tag-push.yml @@ -0,0 +1,24 @@ +# 文件名建议统一为 tag-push.yml +# 应用 publish.yml 的 demo + +name: TAG_PUSH + +on: create + +jobs: + TAG_PUSH: + runs-on: ubuntu-latest + if: github.event.ref_type == 'tag' + steps: + - uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + token: ${{ secrets.PERSONAL_TOKEN }} + - run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git status + git fetch origin + git merge origin/develop + git push origin main From 759596be48497350bf22330162a5b84a357fd429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Fri, 25 Oct 2024 10:24:35 +0800 Subject: [PATCH 2/5] docs: add PUBLISH.md --- PUBLISH.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 PUBLISH.md diff --git a/PUBLISH.md b/PUBLISH.md new file mode 100644 index 00000000..97457958 --- /dev/null +++ b/PUBLISH.md @@ -0,0 +1,19 @@ +# 版本发布流程 + +## 发布频率 + +组件库正常每两周滚动发布版本,一般在周三/周四,尽量不在周五或晚上发布,防止周末非工作时间响应不及时 + +如果遇到用户要求紧急修复 bug,可以视情况发布 PATCH 或先行版本,判断标准: + +- 影响范围大,大多数用户都可能会遇到问题:请遵照正常发布流程严格测试产物质量及整理 CHANGELOG 后发布 PATCH 版本,以使用户可以自动更新到 +- 新上线的功能,仅有少量用户使用:可以不整理 changelog,直接发布先行版本供用户使用,如 `x.y.z-alpha` + +## 发布流程 + +- 从 `develop` 新建 `release/x.y.z` 分支,并修改 `package.json` 中的版本号,推送分支至远程仓库,并提交一个合入`develop`的 Pull Request 到仓库 +- 仓库的 Github Action 会自动整理上个版本至今 commit 对应的 CHANGELOG,并将 CHANGELOG 的 draft 作为一个评论推送到该 Pull Request 上 +- 发布人检查 CHANGELOG,并优化内容逻辑结构,确认无误后删除对于评论首行提示,Github Action 会将优化后的内容写入 CHANGELOG.md 内 +- 确认无误后,合并分支入`develop` +- 合入 `develop` 后,仓库会触发 Github Action 合入 `main` 分支,并将版本号作为 `tag` 打在仓库上,并触发 Github Action 执行 npm 版本发布流程 +- 合入 `main` 分支后,站点的部署流水线 web hook 会监听到 `main` 分支的新增 commit,并触发流水线,官网更新站点 \ No newline at end of file From 9014aa62e1b48c38deaa77c009ed28857d144db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Fri, 25 Oct 2024 10:28:46 +0800 Subject: [PATCH 3/5] docs: update PUBLISH.md --- PUBLISH.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/PUBLISH.md b/PUBLISH.md index 97457958..cd0082af 100644 --- a/PUBLISH.md +++ b/PUBLISH.md @@ -1,14 +1,5 @@ # 版本发布流程 -## 发布频率 - -组件库正常每两周滚动发布版本,一般在周三/周四,尽量不在周五或晚上发布,防止周末非工作时间响应不及时 - -如果遇到用户要求紧急修复 bug,可以视情况发布 PATCH 或先行版本,判断标准: - -- 影响范围大,大多数用户都可能会遇到问题:请遵照正常发布流程严格测试产物质量及整理 CHANGELOG 后发布 PATCH 版本,以使用户可以自动更新到 -- 新上线的功能,仅有少量用户使用:可以不整理 changelog,直接发布先行版本供用户使用,如 `x.y.z-alpha` - ## 发布流程 - 从 `develop` 新建 `release/x.y.z` 分支,并修改 `package.json` 中的版本号,推送分支至远程仓库,并提交一个合入`develop`的 Pull Request 到仓库 From 096fddd20e90e2ecf1398849af0042dd55dffc36 Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Fri, 25 Oct 2024 10:34:20 +0800 Subject: [PATCH 4/5] docs: update PUBLISH.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 悠静萝莉 --- PUBLISH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PUBLISH.md b/PUBLISH.md index cd0082af..5563db03 100644 --- a/PUBLISH.md +++ b/PUBLISH.md @@ -6,5 +6,5 @@ - 仓库的 Github Action 会自动整理上个版本至今 commit 对应的 CHANGELOG,并将 CHANGELOG 的 draft 作为一个评论推送到该 Pull Request 上 - 发布人检查 CHANGELOG,并优化内容逻辑结构,确认无误后删除对于评论首行提示,Github Action 会将优化后的内容写入 CHANGELOG.md 内 - 确认无误后,合并分支入`develop` -- 合入 `develop` 后,仓库会触发 Github Action 合入 `main` 分支,并将版本号作为 `tag` 打在仓库上,并触发 Github Action 执行 npm 版本发布流程 +合入 `develop` 后,仓库会触发 Github Action 合入 `main` 分支,并将版本号作为 `tag` 打在仓库上,并触发 Github Action 执行版本发布流程 - 合入 `main` 分支后,站点的部署流水线 web hook 会监听到 `main` 分支的新增 commit,并触发流水线,官网更新站点 \ No newline at end of file From 390df297178affcc0d55dfd57f417f927eda2da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Fri, 25 Oct 2024 12:48:56 +0800 Subject: [PATCH 5/5] chore: update docs --- PUBLISH.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PUBLISH.md b/PUBLISH.md index 5563db03..d1176edd 100644 --- a/PUBLISH.md +++ b/PUBLISH.md @@ -6,5 +6,4 @@ - 仓库的 Github Action 会自动整理上个版本至今 commit 对应的 CHANGELOG,并将 CHANGELOG 的 draft 作为一个评论推送到该 Pull Request 上 - 发布人检查 CHANGELOG,并优化内容逻辑结构,确认无误后删除对于评论首行提示,Github Action 会将优化后的内容写入 CHANGELOG.md 内 - 确认无误后,合并分支入`develop` -合入 `develop` 后,仓库会触发 Github Action 合入 `main` 分支,并将版本号作为 `tag` 打在仓库上,并触发 Github Action 执行版本发布流程 -- 合入 `main` 分支后,站点的部署流水线 web hook 会监听到 `main` 分支的新增 commit,并触发流水线,官网更新站点 \ No newline at end of file +合入 `develop` 后,仓库会触发 Github Action 合入 `main` 分支,并将版本号作为 `tag` 打在仓库上