Skip to content

Conversation

@oasis-cloud
Copy link
Collaborator

@oasis-cloud oasis-cloud commented Feb 11, 2025

Summary by CodeRabbit

  • Chores

    • 引入全新自动发布流程,利用持续集成实现更高效的发布管理。
    • 新增“Release NPM Packages”工作流,支持自动化管理指定包的发布。
    • 新增“Release 3x Beta”工作流,支持测试场景的干运行发布。
    • 更新版本控制配置,优化仓库结构管理。
    • release 目录添加到 .gitignore 文件中,避免版本控制。
  • Refactor

    • 移除冗余的预发布与后发布处理脚本,进一步简化构建流程。
    • 调整构建和打包脚本,统一输出目录管理,优化发布包生成流程。
    • 增强 TypeScript 声明文件生成的灵活性,改进脚本适应性。

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2025

Warning

Rate limit exceeded

@github-actions[bot] has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 23 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d387997 and 27dd1f9.

📒 Files selected for processing (2)
  • .github/workflows/release-beta.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)

Walkthrough

该PR新增了两个GitHub Actions工作流,用于自动化发布流程,并修改了构建脚本以统一和定制分发目录。同时,更新了.gitignore文件以忽略发布目录,修改了package.json中部分发布前后脚本,并删除了预发布与后发布的辅助脚本,从而简化了包的发布和构建流程。

Changes

文件 变更摘要
.github/workflows/release.yml, .github/workflows/release-beta.yml 新增自动化release工作流,触发条件包括特定分支推送、PR事件和手动触发;包含代码检出、安装pnpm、设置Node环境、依赖安装、构建和npm dry-run发布步骤。
.gitignore 新增忽略规则:/release目录不被版本控制。
package.json 移除 "postpublish": "node scripts/postpublish.js""prepublishOnly": "node scripts/prepublish.js" 脚本,更新repository URL格式。
scripts/build-comments-to-dts.mjs 新增 const dist = 'release/h5/dist',更新 getDtsPath 函数签名以支持自定义输出目录,优化环境变量判断。
scripts/build-taro.mjs, scripts/build.mjs 更新构建路径为 dist 变量管理(分别为 release/taro/distrelease/h5/dist),新增 generateReleasePackageJsoncopyReleaseFiles 函数,实现发布包配置和文件复制。
scripts/postpublish.js, scripts/prepublish.js 删除用于发布前后处理的脚本文件。

Sequence Diagram(s)

sequenceDiagram
  participant Dev as 开发者
  participant GitHub as GitHub系统
  participant Runner as CI Runner
  participant Repo as 代码仓库

  Dev->>GitHub: 推送/更新特定分支或PR
  GitHub->>Runner: 触发release工作流
  Runner->>Repo: 检出代码 (actions/checkout)
  Runner->>Runner: 安装pnpm与设置Node环境
  Runner->>Repo: 安装依赖并执行构建 (pnpm build, build:taro)
  Runner->>Repo: 执行npm publish --dry-run (nutui-react & nutui-react-taro)
  Runner->>GitHub: 汇报工作流执行结果
Loading

Possibly related PRs

Suggested reviewers

  • oasis-cloud
  • xiaoyatong

Poem

我是一只爱改动的小兔子,
跳跃在代码间,轻舞release的节拍;
自动化流程如花儿绽放,
目录与路径精准而美妙;
构建和发布齐声欢唱 ——
代码世界因我而多彩 🐰✨
春风送暖,开发步步高!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) 3.x Target branch 3.x labels Feb 11, 2025
@codecov
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.75%. Comparing base (a9a6292) to head (27dd1f9).
Report is 5 commits behind head on feat_v3.x.

Additional details and impacted files
@@              Coverage Diff              @@
##           feat_v3.x    #2982      +/-   ##
=============================================
+ Coverage      85.74%   85.75%   +0.01%     
=============================================
  Files            277      277              
  Lines          18105    18110       +5     
  Branches        2745     2735      -10     
=============================================
+ Hits           15524    15531       +7     
+ Misses          2576     2574       -2     
  Partials           5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 11, 2025
@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (4)
scripts/build-comments-to-dts.mjs (2)

13-13: 建议将 dist 常量移至共享配置文件

考虑将 dist 常量移至一个共享的配置文件中,以便在所有构建脚本之间共享和维护。这样可以避免重复定义和潜在的不一致性。


139-149: 建议增强 getDtsPath 函数的健壮性

函数可以增加以下改进:

  1. 添加参数类型注解
  2. 添加参数验证
  3. 使用 path.normalize 处理路径

建议按如下方式重构:

-function getDtsPath(key, outDir) {
+function getDtsPath(key: string, outDir: string): string {
+  if (!key || !outDir) {
+    throw new Error('key and outDir are required')
+  }
   // Tabs.Tabpane -> tabpane
   let name
   if (key === 'Tabs.Tabpane') {
     name = 'tabpane'
   } else {
     name = key.toLowerCase().replace('.', '')
   }
-  const file = path.join(__dirname, `../${outDir}/es/packages`, name, name + '.d.ts')
+  const file = path.normalize(path.join(__dirname, `../${outDir}/es/packages`, name, name + '.d.ts'))
   return file
 }
scripts/build.mjs (1)

352-372: 优化 generateReleasePackageJson 函数的性能

使用 delete 操作符可能会影响性能。建议使用对象解构或创建新对象的方式来排除不需要的依赖。

建议按如下方式重构:

 function generateReleasePackageJson() {
-  delete packageJson.dependencies['@nutui/icons-react-taro']
+  const { '@nutui/icons-react-taro': _, ...dependencies } = packageJson.dependencies
   return JSON.stringify({
     name: '@nutui/nutui-react',
     version: packageJson.version,
     style: packageJson.style,
     main: packageJson.main,
     module: packageJson.module,
     typings: packageJson.typings,
     sideEffects: packageJson.sideEffects,
     description: packageJson.description,
     keywords: packageJson.keywords,
     author: packageJson.author,
     license: packageJson.license,
     repository: packageJson.repository,
     files: packageJson.files,
     publishConfig: packageJson.publishConfig,
-    dependencies: packageJson.dependencies,
+    dependencies,
     peerDependencies: packageJson.peerDependencies,
   })
 }
🧰 Tools
🪛 Biome (1.9.4)

[error] 353-355: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

scripts/build-taro.mjs (1)

412-432: 优化 generateReleasePackageJson 函数的性能

使用 delete 操作符可能会影响性能。建议使用对象解构或创建新对象的方式来排除不需要的依赖。

建议按如下方式重构:

 function generateReleasePackageJson() {
-  delete packageJson.dependencies['@nutui/icons-react']
+  const { '@nutui/icons-react': _, ...dependencies } = packageJson.dependencies
   return JSON.stringify({
     name: '@nutui/nutui-react-taro',
     version: packageJson.version,
     style: packageJson.style,
     main: packageJson.main,
     module: packageJson.module,
     typings: packageJson.typings,
     sideEffects: packageJson.sideEffects,
     description: packageJson.description,
     keywords: packageJson.keywords,
     author: packageJson.author,
     license: packageJson.license,
     repository: packageJson.repository,
     files: packageJson.files,
     publishConfig: packageJson.publishConfig,
-    dependencies: packageJson.dependencies,
+    dependencies,
     peerDependencies: packageJson.peerDependencies,
   })
 }
🧰 Tools
🪛 Biome (1.9.4)

[error] 416-418: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 565fc8d and 81e49f6.

📒 Files selected for processing (8)
  • .github/workflows/release.yml (1 hunks)
  • .gitignore (1 hunks)
  • package.json (0 hunks)
  • scripts/build-comments-to-dts.mjs (3 hunks)
  • scripts/build-taro.mjs (18 hunks)
  • scripts/build.mjs (17 hunks)
  • scripts/postpublish.js (0 hunks)
  • scripts/prepublish.js (0 hunks)
💤 Files with no reviewable changes (3)
  • scripts/postpublish.js
  • scripts/prepublish.js
  • package.json
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🧰 Additional context used
🪛 Biome (1.9.4)
scripts/build.mjs

[error] 353-355: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

scripts/build-taro.mjs

[error] 416-418: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🪛 actionlint (1.7.4)
.github/workflows/release.yml

3-3: could not parse as YAML: yaml: line 3: mapping values are not allowed in this context

(syntax-check)

🪛 YAMLlint (1.35.1)
.github/workflows/release.yml

[error] 3-3: syntax error: mapping values are not allowed here

(syntax)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/release.yml (1)

34-38: 建议添加发布前验证步骤

在执行发布操作之前,建议添加版本号验证和包内容检查步骤,以确保发布内容的正确性。

建议在发布步骤之前添加以下验证:

      - name: Verify Package Versions
        run: |
          echo "Verifying @nutui/nutui-react version..."
          jq -r .version ./release/h5/package.json
          echo "Verifying @nutui/nutui-react-taro version..."
          jq -r .version ./release/taro/package.json

      - name: Verify Package Contents
        run: |
          echo "Checking @nutui/nutui-react contents..."
          ls -la ./release/h5
          echo "Checking @nutui/nutui-react-taro contents..."
          ls -la ./release/taro
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81e49f6 and b1e3750.

📒 Files selected for processing (1)
  • .github/workflows/release.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/release.yml

6-6: character '.' is invalid for branch and tag names. ref name must not end with / and .. see man git-check-ref-format for more details. note that regular expression is unavailable. note: filter pattern syntax is explained at https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

(glob)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (3)
.github/workflows/release.yml (3)

20-21: 完善 pnpm 版本指定

pnpm 版本号指定不完整,可能导致安装不稳定。

-run:  npm install -g pnpm@v9
+run: npm install -g pnpm@9

31-32: 优化构建命令执行顺序

当前的构建命令使用 & 并行执行,但缺乏错误处理。建议使用 && 串行执行以确保第一个命令成功后再执行第二个命令。

-run: pnpm build & pnpm build:taro
+run: pnpm build && pnpm build:taro

37-38: 优化目录导航路径

使用相对路径 ../../ 进行目录导航可能不可靠。建议使用从工作目录开始的路径。

-run: cd ../../release/taro && npm publish --dry-run
+run: cd ./release/taro && npm publish --dry-run

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 11, 2025
@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.github/workflows/release.yml (2)

34-38: 建议添加发布前的包内容验证

在发布之前,建议添加步骤来验证包的内容,确保所有必要的文件都已正确打包。

      - name: Verify Package Contents
        run: |
          cd ./release/h5 && npm pack --dry-run
          cd ../taro && npm pack --dry-run

11-16: 建议增强工作流程的稳健性

为了提高发布过程的可靠性,建议:

  1. 添加 Node.js 版本矩阵测试
  2. 添加 npm 凭证验证步骤
jobs:
  release:
    strategy:
      matrix:
        node-version: [18.x, 20.x]
    steps:
      # ... existing steps ...
      - name: Verify NPM Credentials
        run: npm whoami
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1e3750 and 3c509e1.

📒 Files selected for processing (1)
  • .github/workflows/release.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/release.yml

6-6: character '.' is invalid for branch and tag names. ref name must not end with / and .. see man git-check-ref-format for more details. note that regular expression is unavailable. note: filter pattern syntax is explained at https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

(glob)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: test
🔇 Additional comments (4)
.github/workflows/release.yml (4)

4-7: 修复分支名称模式

分支名称模式 feat_v3.x. 以句点结尾是无效的。这可能会导致工作流触发失败。

-      - feat_v3.x.
+      - feat_v3.x
🧰 Tools
🪛 actionlint (1.7.4)

6-6: character '.' is invalid for branch and tag names. ref name must not end with / and .. see man git-check-ref-format for more details. note that regular expression is unavailable. note: filter pattern syntax is explained at https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

(glob)


20-21: 修复 pnpm 版本指定

pnpm 版本号指定不完整,建议指定完整的版本号以确保安装的稳定性。

-run:  npm install -g pnpm@v9
+run: npm install -g pnpm@9.x.x

31-32: 改进构建命令的错误处理

当前使用 & 并行执行构建命令可能会掩盖错误。建议使用 && 确保命令按顺序执行且出错时能及时停止。

-run: pnpm build & pnpm build:taro
+run: pnpm build && pnpm build:taro

37-38: 优化目录导航路径

使用 ../../ 这样的相对路径可能导致导航错误。建议使用更可靠的绝对路径。

-run: cd ../../release/taro && npm publish --dry-run
+run: cd ./release/taro && npm publish --dry-run

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 11, 2025
@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 11, 2025
@github-actions github-actions bot added the action:review This PR needs more reviews (less than 2 approvals) label Feb 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
.github/workflows/release-beta.yml (2)

47-49: 🛠️ Refactor suggestion

使用锁定的依赖版本

在 CI 环境中应该使用锁定的依赖版本,以确保构建的一致性。

 - name: Install dependencies
   if: env.ABORT != 'true'
-  run: pnpm install --no-frozen-lockfile
+  run: pnpm install --frozen-lockfile

51-61: 🛠️ Refactor suggestion

优化构建和发布步骤

当前实现存在以下问题:

  1. 构建命令缺少错误处理
  2. 发布步骤使用了硬编码的标签
  3. 缺少文件末尾的换行符
 - name: Run Build
   if: env.ABORT != 'true'
-  run: pnpm build && pnpm build:taro
+  run: |
+    if ! pnpm build; then
+      echo "构建 nutui-react 失败"
+      exit 1
+    fi
+    if ! pnpm build:taro; then
+      echo "构建 nutui-react-taro 失败"
+      exit 1
+    fi

 - name: Run Release @nutui/nutui-react
   if: env.ABORT != 'true'
-  run: cd ./release/h5 && npm publish --dry-run --tag beta
+  run: |
+    cd ./release/h5 || exit 1
+    if ! npm publish --dry-run --tag ${RELEASE_TAG:-beta}; then
+      echo "发布 @nutui/nutui-react 失败"
+      exit 1
+    fi

 - name: Run Releases @nutui/nutui-react-taro
   if: env.ABORT != 'true'
-  run: cd ./release/taro && npm publish --dry-run --tag beta
+  run: |
+    cd ./release/taro || exit 1
+    if ! npm publish --dry-run --tag ${RELEASE_TAG:-beta}; then
+      echo "发布 @nutui/nutui-react-taro 失败"
+      exit 1
+    fi
+
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 61-61: no new line character at the end of file

(new-line-at-end-of-file)

🧹 Nitpick comments (1)
.github/workflows/release-beta.yml (1)

3-10: 建议添加手动触发功能

工作流程应该支持手动触发,以便于测试和紧急发布。

 on:
   push:
     branches:
       - feat_v3.x
   pull_request:
     branches:
       - feat_v3.x
+  workflow_dispatch:
+    inputs:
+      tags:
+        description: '发布包版本类型'
+        required: true
+        default: 'beta'
+        type: choice
+        options:
+          - beta
+          - alpha
+      publish:
+        description: '是否发布'
+        required: false
+        type: boolean
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efea6cd and 4798d00.

📒 Files selected for processing (1)
  • .github/workflows/release-beta.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/release-beta.yml

[error] 61-61: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test

Comment on lines 24 to 38
- name: Get commit message
run: |
COMMIT_MESSAGE=$(git log --format=%s -n 1)
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
- name: Show commit message
run: echo "$COMMIT_MESSAGE"

- name: Commit message compliance verification
if: startsWith( env.COMMIT_MESSAGE , 'chore(release):' ) != true && contains( env.COMMIT_MESSAGE , '-beta' ) != true
run: echo "ABORT=true" >> $GITHUB_ENV

- name: Get Tag message
if: contains( env.COMMIT_MESSAGE , '-beta')
run: echo "RELEASE_TAG=beta" >> $GITHUB_ENV

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

改进提交消息处理的安全性和可靠性

当前的提交消息处理存在以下问题:

  1. 直接在环境变量中使用未经过滤的提交消息可能存在安全风险
  2. 条件判断可以更简洁和可靠
 - name: Get commit message
   run: |
-    COMMIT_MESSAGE=$(git log --format=%s -n 1)
-    echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
+    # 使用 shell 参数扩展来过滤特殊字符
+    COMMIT_MESSAGE=$(git log --format=%s -n 1)
+    FILTERED_MESSAGE="${COMMIT_MESSAGE//[^a-zA-Z0-9.()_:, -]/}"
+    echo "COMMIT_MESSAGE=${FILTERED_MESSAGE}" >> $GITHUB_ENV

 - name: Show commit message
   run: echo "$COMMIT_MESSAGE"

 - name: Commit message compliance verification
-  if: startsWith( env.COMMIT_MESSAGE , 'chore(release):' ) != true && contains( env.COMMIT_MESSAGE , '-beta' ) != true
+  if: |
+    !startsWith(env.COMMIT_MESSAGE, 'chore(release):') ||
+    !contains(env.COMMIT_MESSAGE, '-beta')
   run: echo "ABORT=true" >> $GITHUB_ENV
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Get commit message
run: |
COMMIT_MESSAGE=$(git log --format=%s -n 1)
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
- name: Show commit message
run: echo "$COMMIT_MESSAGE"
- name: Commit message compliance verification
if: startsWith( env.COMMIT_MESSAGE , 'chore(release):' ) != true && contains( env.COMMIT_MESSAGE , '-beta' ) != true
run: echo "ABORT=true" >> $GITHUB_ENV
- name: Get Tag message
if: contains( env.COMMIT_MESSAGE , '-beta')
run: echo "RELEASE_TAG=beta" >> $GITHUB_ENV
- name: Get commit message
run: |
# 使用 shell 参数扩展来过滤特殊字符
COMMIT_MESSAGE=$(git log --format=%s -n 1)
FILTERED_MESSAGE="${COMMIT_MESSAGE//[^a-zA-Z0-9.()_:, -]/}"
echo "COMMIT_MESSAGE=${FILTERED_MESSAGE}" >> $GITHUB_ENV
- name: Show commit message
run: echo "$COMMIT_MESSAGE"
- name: Commit message compliance verification
if: |
!startsWith(env.COMMIT_MESSAGE, 'chore(release):') ||
!contains(env.COMMIT_MESSAGE, '-beta')
run: echo "ABORT=true" >> $GITHUB_ENV
- name: Get Tag message
if: contains( env.COMMIT_MESSAGE , '-beta')
run: echo "RELEASE_TAG=beta" >> $GITHUB_ENV

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 11, 2025
@xiaoyatong
Copy link
Collaborator

可参考ai建议修订

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 13, 2025
@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (3)
.github/workflows/release.yml (1)

19-19: ⚠️ Potential issue

完善 pnpm 版本号

当前的 pnpm 版本号不完整,这可能导致安装不稳定。建议指定完整的版本号。

-  run:  npm install -g pnpm@v9
+  run: npm install -g pnpm@9.8.0
.github/workflows/release-beta.yml (2)

19-22: 🛠️ Refactor suggestion

优化代码检出配置

当前的 ref 配置仅在 PR 事件时有效,这可能导致手动触发时失败。

 - uses: actions/checkout@v4
   with:
     fetch-depth: 0
-    ref: ${{ github.event.pull_request.head.sha }}
+    ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

52-52: 🛠️ Refactor suggestion

建议使用锁定的依赖版本

在 CI 环境中使用 --no-frozen-lockfile 可能导致构建不一致。

-run: pnpm install --no-frozen-lockfile
+run: pnpm install --frozen-lockfile
🧹 Nitpick comments (3)
.github/workflows/release.yml (1)

4-7: 建议优化标签触发模式

当前的标签模式 v3.* 过于宽泛,可能会意外触发不需要的发布。建议使用更具体的模式来匹配语义化版本。

  push:
    tags:
-      - v3.*
+      - v3.[0-9]+.[0-9]+
.github/workflows/release-beta.yml (2)

24-36: 改进提交消息处理的安全性和可靠性

当前的提交消息验证逻辑有以下问题:

  1. 条件表达式可以更简洁
  2. 错误处理机制不够完善
 - name: Commit message compliance verification
   if: |
-    !startsWith( env.COMMIT_MESSAGE , 'chore(release):' ) ||
-    !contains( env.COMMIT_MESSAGE , '-beta' )
+    !startsWith(env.COMMIT_MESSAGE, 'chore(release):') ||
+    !contains(env.COMMIT_MESSAGE, '-beta')
   run: |
     echo "ABORT=true" >> $GITHUB_ENV
+    echo "::error ::提交消息不符合发布规范"
+    exit 1

66-82: 改进发布步骤的错误处理

发布步骤缺少文件末尾的换行符,且错误消息可以更明确。

 - name: Run Release @nutui/nutui-react
   if: env.ABORT != 'true'
   run: |
     cd ./release/h5 || exit 1
     if ! npm publish --dry-run --tag ${{ env.RELEASE_TAG }}; then
-      echo "发布 @nutui/nutui-react 失败"
+      echo "::error ::发布 @nutui/nutui-react (${RELEASE_TAG}) 失败"
       exit 1
     fi

 - name: Run Releases @nutui/nutui-react-taro
   if: env.ABORT != 'true'
   run: |
     cd ./release/taro || exit 1
     if ! npm publish --dry-run --tag ${{ env.RELEASE_TAG }}; then
-      echo "发布 @nutui/nutui-react-taro 失败"
+      echo "::error ::发布 @nutui/nutui-react-taro (${RELEASE_TAG}) 失败"
       exit 1
     fi
+
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4798d00 and 0419a9f.

📒 Files selected for processing (2)
  • .github/workflows/release-beta.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/release.yml

10-10: invalid job ID "release-3.x". job ID must start with a letter or _ and contain only alphanumeric characters, -, or _

(id)

.github/workflows/release-beta.yml

11-11: invalid job ID "release-3.x-beta". job ID must start with a letter or _ and contain only alphanumeric characters, -, or _

(id)

🪛 YAMLlint (1.35.1)
.github/workflows/release-beta.yml

[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: test
🔇 Additional comments (1)
.github/workflows/release.yml (1)

30-30: 建议添加环境变量验证

当前使用了 env.ABORT 变量进行条件判断,但未见该变量的定义。建议在使用前验证该变量。

+      - name: Validate environment
+        run: |
+          if [ -z "$RELEASE_TAG" ]; then
+            echo "RELEASE_TAG 环境变量未设置"
+            exit 1
+          fi
+
       - name: Run Build
         if: env.ABORT != 'true'

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
.github/workflows/release-beta.yml (3)

50-53: 🛠️ Refactor suggestion

建议使用锁定的依赖版本

使用 --no-frozen-lockfile 可能导致不同环境下的构建结果不一致。

建议在 CI 环境中始终使用锁定的依赖版本:

 - name: Install dependencies
   if: env.ABORT != 'true'
-  run: pnpm install --no-frozen-lockfile
+  run: pnpm install --frozen-lockfile

19-22: 🛠️ Refactor suggestion

优化代码检出配置

当前的 ref 配置仅在 PR 事件时有效,可能导致其他触发方式失败。

建议根据事件类型动态设置:

 - uses: actions/checkout@v4
   with:
     fetch-depth: 0
-    ref: ${{ github.event.pull_request.head.sha }}
+    ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

1-16: ⚠️ Potential issue

工作流配置需要改进

  1. 作业ID release-3x-beta 包含无效字符(连字符),这可能导致问题
  2. 工作流触发器配置不完整,缺少手动触发所需的输入参数

建议进行以下修改:

 name: Release 3x Beta

 on:
   pull_request:
#  push:
     branches:
       - feat_v3.x
   workflow_dispatch:
+    inputs:
+      tags:
+        description: '发布包版本类型'
+        required: true
+        default: 'beta'
+        type: choice
+        options:
+          - beta
+          - alpha
+      publish:
+        description: '是否发布'
+        required: false
+        type: boolean

 jobs:
-  release-3x-beta:
+  release_3x_beta:
     env:
       NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
       NPM_CONFIG_PROVENANCE: true
-      RELEASE_TAG: beta
+      RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tags || 'beta' }}
🧹 Nitpick comments (2)
.github/workflows/release-beta.yml (2)

24-36: 改进提交消息处理的安全性

虽然已经添加了基本的字符过滤,但提交消息处理的条件判断可以更简洁和可靠。

建议修改条件判断:

 - name: Commit message compliance verification
   if: |
-    !startsWith( env.COMMIT_MESSAGE , 'chore(release):' ) ||
-    !contains( env.COMMIT_MESSAGE , '-beta' )
+    !startsWith(env.COMMIT_MESSAGE, 'chore(release):') ||
+    !contains(env.COMMIT_MESSAGE, '-beta')
   run: echo "ABORT=true" >> $GITHUB_ENV

66-82: 改进发布步骤的错误处理

发布步骤已经包含了基本的错误处理,但缺少文件末尾的换行符。

建议在文件末尾添加换行符:

           if ! npm publish --dry-run --tag ${{ env.RELEASE_TAG }}; then
             echo "发布 @nutui/nutui-react-taro 失败"
             exit 1
           fi
+
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0419a9f and d5b1d9d.

📒 Files selected for processing (2)
  • .github/workflows/release-beta.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/release.yml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/release-beta.yml

[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (4)
.github/workflows/release-beta.yml (4)

51-54: 🛠️ Refactor suggestion

建议使用锁定的依赖版本

使用 --no-frozen-lockfile 可能导致不同环境下的构建结果不一致。

建议修改为:

 - name: Install dependencies
   if: env.ABORT != 'true'
-  run: pnpm install --no-frozen-lockfile
+  run: pnpm install --frozen-lockfile

20-23: 🛠️ Refactor suggestion

优化代码检出配置

当前的 ref 配置仅在 PR 事件时有效,这可能导致其他触发方式失败。

建议应用以下修改:

 - uses: actions/checkout@v4
   with:
     fetch-depth: 0
-    ref: ${{ github.event.pull_request.head.sha }}
+    ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

11-17: ⚠️ Potential issue

修复作业 ID 和环境变量配置

  1. 作业 ID release-3x-beta 包含无效字符
  2. RELEASE_TAG 环境变量没有考虑手动触发的情况

建议应用以下修改:

 jobs:
-  release-3x-beta:
+  release_3x_beta:
     env:
       NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
       NPM_CONFIG_PROVENANCE: true
-      RELEASE_TAG: beta
+      RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tags || 'beta' }}

1-10: ⚠️ Potential issue

工作流触发器配置需要改进

工作流配置缺少手动触发所需的输入参数,这可能导致手动触发时出现问题。

建议应用以下修改:

 name: Release 3x Beta

 on:
   pull_request:
#  push:
     branches:
       - feat_v3.x
   workflow_dispatch:
+    inputs:
+      tags:
+        description: '发布包版本类型'
+        required: true
+        default: 'beta'
+        type: choice
+        options:
+          - beta
+          - alpha
+      publish:
+        description: '是否发布'
+        required: false
+        type: boolean
🧹 Nitpick comments (1)
.github/workflows/release-beta.yml (1)

83-83: 添加文件末尾的换行符

YAML 文件末尾缺少换行符。

在文件末尾添加一个空行。

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 83-83: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5b1d9d and 8f16cea.

📒 Files selected for processing (1)
  • .github/workflows/release-beta.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/release-beta.yml

[error] 83-83: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build
  • GitHub Check: release-3x-beta
  • GitHub Check: test

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/release-beta.yml (1)

1-16: ⚠️ Potential issue

工作流配置需要改进

工作流配置存在以下问题:

  1. 作业ID release-3x-beta 包含无效字符,可能导致问题
  2. 缺少手动触发的输入参数配置
  3. PR触发器被注释掉,可能影响开发流程

建议进行以下修改:

 name: Release 3x Beta

 on:
-#  pull_request:
+  pull_request:
   push:
     branches:
       - feat_v3.x
   workflow_dispatch:
+    inputs:
+      tags:
+        description: '发布包版本类型'
+        required: true
+        default: 'beta'
+        type: choice
+        options:
+          - beta
+          - alpha
+      publish:
+        description: '是否发布'
+        required: false
+        type: boolean

 jobs:
-  release-3x-beta:
+  release_3x_beta:
     env:
       NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
       NPM_CONFIG_PROVENANCE: true
-      RELEASE_TAG: beta
+      RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tags || 'beta' }}
🧹 Nitpick comments (1)
.github/workflows/release-beta.yml (1)

24-49: 改进环境配置和提交消息处理

环境配置有以下改进空间:

  1. 提交消息过滤可以更严格
  2. pnpm版本应该使用范围版本
  3. Node.js版本应考虑LTS版本

建议进行以下修改:

       - name: Get commit message
         run: |
           COMMIT_MESSAGE=$(git log --format=%s -n 1)
-          FILTERED_MESSAGE="${COMMIT_MESSAGE//[^a-zA-Z0-9.()_:, -]/}"
+          FILTERED_MESSAGE="${COMMIT_MESSAGE//[^a-zA-Z0-9.()_:,@/ -]/}"
           echo "COMMIT_MESSAGE=${FILTERED_MESSAGE}" >> $GITHUB_ENV

       - name: Install pnpm
-        run: npm install -g pnpm@v9
+        run: npm install -g pnpm@^9.0.0

       - uses: actions/setup-node@v4
         with:
-          node-version: '20'
+          node-version: '20.11.1'  # LTS版本
           cache: 'pnpm'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f16cea and d387997.

📒 Files selected for processing (1)
  • .github/workflows/release-beta.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/release-beta.yml

[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: test

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) and removed action:review This PR needs more reviews (less than 2 approvals) labels Feb 13, 2025
@xiaoyatong xiaoyatong merged commit ccdd594 into jdf2e:feat_v3.x Feb 13, 2025
8 checks passed
oasis-cloud added a commit to oasis-cloud/nutui-react that referenced this pull request Feb 20, 2025
* chore: release package via ci

* chore: release package via ci

* chore: release package via ci

* chore: release package via ci

* chore: release package via ci

* chore: release package via ci

* chore: release package via ci

* chore: release package via ci

* chore: release package via ci

* chore: 测试手动执行

* chore: 测试手动执行

* chore: 测试手动执行

* chore: 测试手动执行

* chore: 测试手动执行

* chore: 测试手动执行

* chore: 测试手动执行

* chore: 测试手动执行

* chore: 测试手动执行

* chore: 测试手动执行

* chore: 测试beta

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* fix: review

* fix: review

* chore(release): v3.0.0-beta.12

* chore(release): v3.0.0-beta.12

* chore: remove --dry-run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants