zenstruck/changelog

使用提交日志和GitHub API生成漂亮的发布变更日志。

资助包维护!
kbond

v1.7.5 2024-07-12 15:54 UTC

This package is auto-updated.

Last update: 2024-09-12 16:11:34 UTC


README

CI

使用提交日志和GitHub API生成漂亮的发布变更日志。变更日志条目格式如下

{short hash} {summary} (#{PR number}) by {author}, {co-author 1}, {co-author n}...

有关格式的说明

  1. 目前,此格式是硬编码的,无法自定义
  2. 合并提交被排除
  3. 如果摘要中尚未添加,则仅添加PR编号(并且为提交存在PR)
  4. 如果可能,将作者/共同作者转换为GitHub用户名链接,以利用GitHub发布头像列表

请参阅使用此包生成的发布示例

安装

为了避免与此工具的依赖冲突,建议将其作为可执行PHAR安装,或使用composer bin 插件在您的项目(或全局)中安装。

PHAR

wget https://github.com/zenstruck/changelog/releases/latest/download/changelog.phar -O changelog && chmod +x changelog
mv changelog ~/bin # assumes ~/bin is in your PATH

Composer Bin 插件

需要bamarni/composer-bin-plugin

# locally in your project
composer bin changelog require zenstruck/changelog

# globally
composer global bin changelog require zenstruck/changelog

配置

changelog 二进制文件应该是可执行的,无论是全局的还是通过 vendor/bin/changelog。在本文档的其余部分,假定它可用作 changelog

此工具需要GitHub个人访问令牌以访问GitHub API。您可以通过两种方式配置此令牌

  1. GITHUB_API_TOKEN 环境变量(例如,在 changelog 命令前加上 GITHUB_API_TOKEN=your-token
  2. 全局配置令牌:运行 changelog configure 并按照说明生成/保存您的令牌

用法

注意:检测当前目录中仓库的命令使用可用的 upstream origin。

变更日志预览

在您的控制台生成变更日志预览

# "interactive", detects repository from current directory, from=last release on GitHub, to=default branch
changelog generate

# equivalent to above, "generate" is the "default command"
changelog

# outputs changelog for "your/repository" from tag "v1.0.0" to branch "main"
changelog generate --repository=your/repository --from=v1.0.0 --to=main

运行 changelog generate --help 以查看完整的命令文档。

创建变更日志文件

根据现有发布创建当前仓库的 CHANGELOG.md 文件。该文件将创建在当前工作目录中。您需要自己添加/提交到仓库。

# create a CHANGELOG.md
bin/changelog file:create

# customize the filename
bin/changelog file:create --filename=changes.md

# exclude releases marked as "pre-release"
bin/changelog file:create --exclude-pre-releases

创建发布

创建(可选地推送)发布变更日志(省略 --push 以预览发布的样式)

# "interactive" - detects repository from current directory, suggests next version
changelog release

# generates changelog from v1.0.0 to main and creates v1.1.0 release on GitHub that has the changelog as the body
changelog release v1.1.0 --repository=your/repository --from=v1.0.0 --target=main --push

# detects repository from current directory, from=last release on GitHub, target=default branch
changelog release v1.1.0 --push

您可以使用语义化版本关键词作为下一个版本。以下示例假设您的上一个发布是 v1.0.0

changelog release bug --push # creates v1.0.1 release
changelog release feature --push # creates v1.1.0 release
changelog release major --push # creates v2.0.0 release

运行 changelog release --help 以查看完整的命令文档。

发布状态仪表板

为GitHub组织生成简单的仪表板,显示包发布状态。

changelog dashboard my-org

# will ask for organization and give option to save as default.
# if saved, subsequent calls to the command will not require the organization argument
changelog dashboard