goreleaser 通过 .goreleaser.yaml 中的 release 配置项来过滤提交信息。使用 ignore 字段配合正则表达式,可以排除包含特定关键词(如 [skip ci])的提交,从而避免这些提交出现在 release notes 中。

如何忽略包含特定标记的提交?
在 .goreleaser.yaml 中配置 release.ignore 为正则表达式即可。例如,忽略所有包含 [skip ci] 的提交。

version: 2
release:
github:
owner: your-username
name: your-repo
ignore:
- \'\[skip ci\]\'
上述配置会确保任何提交消息中包含 [skip ci] 的提交都不会被纳入 Release Notes。这是最常用的过滤方式之一。
如何基于提交类型过滤?
除了忽略特定标记,还可以根据提交类型进行过滤。例如,忽略所有 chore 类型的提交。

version: 2
release:
github:
owner: your-username
name: your-repo
ignore:
- \'^chore\:'
此配置将忽略所有以 chore: 开头的提交,从而保持 Release Notes 的简洁性。
如果提交信息为空或特殊字符怎么办?
当提交信息为空或包含特殊字符时,GoReleaser 默认会将其视为普通提交并纳入 Release Notes。可以通过更复杂的正则表达式来处理这些情况。例如,忽略空提交信息和包含 WIP 的提交。
version: 2
release:
github:
owner: your-username
name: your-repo
ignore:
- \'^$\' # 忽略空提交信息
- \'WIP\' # 忽略包含 WIP 的提交
这种配置确保了只有符合预期的提交才会出现在 Release Notes 中,提高了发布记录的准确性和可读性。


















