zenstruck / changelog
使用提交日志和GitHub API生成漂亮的发布变更日志。
v1.7.5
2024-07-12 15:54 UTC
Requires
- php: >=8.0
- composer/semver: ^3.3
- laravel-zero/phar-updater: ^1.1.1
- symfony/cache: ^5.4
- symfony/console: ^5.4
- symfony/filesystem: ^5.4
- symfony/http-client: ^5.4
- symfony/polyfill-php80: ^1.16
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/phpunit-bridge: ^6.2
- symfony/var-dumper: ^5.4
- zenstruck/console-test: ^1.0
README
使用提交日志和GitHub API生成漂亮的发布变更日志。变更日志条目格式如下
{short hash} {summary} (#{PR number}) by {author}, {co-author 1}, {co-author n}...
有关格式的说明
- 目前,此格式是硬编码的,无法自定义
- 合并提交被排除
- 如果摘要中尚未添加,则仅添加PR编号(并且为提交存在PR)
- 如果可能,将作者/共同作者转换为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。您可以通过两种方式配置此令牌
GITHUB_API_TOKEN
环境变量(例如,在changelog
命令前加上GITHUB_API_TOKEN=your-token
)- 全局配置令牌:运行
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