Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: support generate release pr via release-please workflow #535

Closed
wants to merge 2 commits into from

Conversation

skyclouds2001
Copy link
Owner

@skyclouds2001 skyclouds2001 commented Dec 29, 2024

Summary

How did you test this change?

Summary by CodeRabbit

  • 新功能

    • 添加了新的 GitHub Actions 工作流程,用于自动化发布管理
    • 引入了发布配置文件,简化版本控制流程
  • 配置更新

    • 设置了新的发布配置和清单文件
    • 为项目配置了 1.7.0 版本号
    • 更新了发布配置文件以包含更多的发布管理元素

Copy link

coderabbitai bot commented Dec 29, 2024

变更概述

演练

这个拉取请求引入了一个新的 GitHub Actions 工作流程 prepare-release.yml,用于自动化发布管理。同时添加了两个配置文件 .release-please-manifest.jsonrelease-please-config.json,这些文件配置了版本发布的参数和设置。工作流程专门针对 skyclouds2001/template-sky 仓库,并使用 release-please-action 来处理发布流程。

变更

文件 变更摘要
.github/workflows/prepare-release.yml 新增 GitHub Actions 工作流程,触发于 master 分支推送,使用 release-please-action 进行发布
.release-please-manifest.json 新建文件,设置版本为 1.7.0
release-please-config.json 更新配置文件,定义发布类型为 Node.js 项目,增加 changelog 部分

诗歌

🐰 发布兔子的小诗 🚀

代码如流水,版本如歌
自动发布,轻松又和谐
工作流启动,兔子欢笑
新版本来了,技术飞翔!


🪧 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.

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.

@skyclouds2001 skyclouds2001 marked this pull request as ready for review December 29, 2024 09:47
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 (2)
.github/workflows/prepare-release.yml (2)

3-11: 建议增加主分支保护

工作流程在推送到 master 分支时触发。建议:

  1. 启用分支保护规则,禁止直接推送到 master
  2. 改用 pull_request 触发器,确保所有更改都经过审查

权限配置已正确设置,符合最小权限原则。


13-17: 优化作业配置以提高可重用性和效率

当前配置存在以下可优化点:

  1. 硬编码的仓库名称 skyclouds2001/template-sky 限制了工作流程的可重用性
  2. 60分钟的超时时间对于发布准备任务来说可能过长

建议应用以下改进:

  prepare-release:
    name: Prepare release
-   if: github.repository == 'skyclouds2001/template-sky'
+   if: ${{ github.repository == vars.ALLOWED_REPOSITORY }}
-   timeout-minutes: 60
+   timeout-minutes: 15
    runs-on: ubuntu-latest
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b09f18 and 5f2b968.

📒 Files selected for processing (3)
  • .github/workflows/prepare-release.yml (1 hunks)
  • .release-please-manifest.json (1 hunks)
  • release-please-config.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .release-please-manifest.json
  • release-please-config.json
🔇 Additional comments (1)
.github/workflows/prepare-release.yml (1)

1-21: 验证发布工作流集成

在合并之前,请验证:

  1. 与现有的 CI/CD 流程的兼容性
  2. 是否存在重复的发布自动化工具
  3. 版本号管理策略是否符合项目要求
✅ Verification successful

Let me check the content of the release.yml workflow to understand if there are any conflicts.


Let me fix the file search command to properly check other configuration files.


发布工作流配置验证完成

基于验证结果,当前的发布工作流配置是合理的:

  1. 工作流职责划分清晰:

    • prepare-release.yml 负责版本更新和创建发布PR
    • release.yml 负责在标签推送后执行 GitHub 发布和 npm 包发布
  2. 版本管理配置完整:

    • 使用 release-please 进行版本管理
    • package.json 中已配置版本信息
    • CHANGELOG.md 文件存在用于记录变更
  3. 自动化流程完整:

    • 支持 GitHub Release 发布
    • 支持 npm 包发布
    • 包含适当的权限控制
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否存在其他发布相关的工作流程
echo "检查其他发布工作流..."
fd -e yml -e yaml . .github/workflows -x grep -l "release" {}

# 检查包版本管理配置
echo "检查版本管理配置..."
fd -g "package.json" -x jq -r '.version'
fd -g "release-please-config.json" -x cat {}

Length of output: 746


Script:

#!/bin/bash
# 检查 release.yml 的内容
echo "检查 release.yml 的内容..."
cat .github/workflows/release.yml

# 检查是否有其他与版本或发布相关的配置
echo "检查其他配置文件..."
fd -g ".*rc" -g ".*json" -x grep -l "version\|release" {}

Length of output: 1632


Script:

#!/bin/bash
# 检查其他配置文件
echo "检查配置文件..."
fd -e json -e rc . -x grep -l "version\|release" {}

# 检查 CHANGELOG.md 是否存在及其内容
echo "检查 CHANGELOG.md..."
test -f CHANGELOG.md && echo "CHANGELOG.md 存在" || echo "CHANGELOG.md 不存在"

Length of output: 306

Comment on lines +19 to +21
- uses: googleapis/[email protected]
with:
release-type: node
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

完善 release-please-action 配置

当前配置过于简单,建议添加以下重要配置项以增强发布管理:

  - uses: googleapis/[email protected]
    with:
      release-type: node
+     package-name: ${{ vars.PACKAGE_NAME }}
+     changelog-types: |
+       [
+         {"type":"feat","section":"✨ 新功能","hidden":false},
+         {"type":"fix","section":"🐛 问题修复","hidden":false},
+         {"type":"docs","section":"📝 文档","hidden":false},
+         {"type":"chore","section":"📦 杂项","hidden":true}
+       ]
+     bootstrap-sha: ${{ vars.INITIAL_VERSION_SHA }}
+     token: ${{ secrets.GITHUB_TOKEN }}

这些配置将帮助:

  1. 正确设置包名称
  2. 自定义更新日志格式
  3. 设置版本历史起点
  4. 明确指定令牌来源

Committable suggestion skipped: line range outside the PR's diff.

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)
release-please-config.json (2)

5-10: 建议优化 changelog 分类

当前的变更日志分类已经涵盖了主要类型,但建议考虑添加以下常见类型:

  • perf: 性能优化
  • test: 测试相关
  • ci: CI/CD 变更
 "changelog-sections": [
   { "type": "feat", "section": "Features", "hidden": false },
   { "type": "fix", "section": "Bug Fixes", "hidden": false },
   { "type": "docs", "section": "Documentations", "hidden": false },
+  { "type": "perf", "section": "Performance", "hidden": false },
+  { "type": "test", "section": "Tests", "hidden": false },
+  { "type": "ci", "section": "CI/CD", "hidden": false },
   { "type": "chore", "section": "Miscellaneous", "hidden": false }
 ],

11-14: 包配置结构合理

当前的包配置适用于单包项目,设置正确。如果未来需要支持 monorepo,可以在此处添加其他包的配置。

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f2b968 and 170dac8.

📒 Files selected for processing (1)
  • release-please-config.json (1 hunks)
🔇 Additional comments (3)
release-please-config.json (3)

2-2: 配置文件架构验证设置正确!

使用 schema URL 可以确保配置文件格式的正确性,这是一个很好的实践。


4-4: 确认 node release-type 的适用性

配置使用了 "node" 作为发布类型,这与项目的 package.json 相匹配。


3-3: 验证 last-release-sha 的有效性

需要确保这个 SHA 值确实对应于最后一次发布的提交。

@skyclouds2001 skyclouds2001 deleted the release-please branch December 29, 2024 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant