我正在使用这个 bash 脚本自动升级我的项目版本:
#!/usr/bin/env bash
CHANGELOG="Changelog.md"
DEBIAN_CHANGELOG="debian/changelog"
UPSTREAM_VERSION=$(cat VERSION)
# Updating entries in rpm files
DEB_RELEASE_NOTES=$(awk '{print " * " $0}' < RELEASE_NOTES)
echo "Adding new Debian changelog entry for version $UPSTREAM_VERSION."
dch -D unstable -m "$DEB_RELEASE_NOTES" --newversion "$UPSTREAM_VERSION-0debian1-unstable1"
# Prompt user to edit Debian changelog
$EDITOR_CHOICE "$DEBIAN_CHANGELOG"
echo "Version updated successfully: $UPSTREAM_VERSION"
它的作用是同步并将版本放在 rpm 和 debian 包中。但是这个命令:
dch -D unstable -m "$DEB_RELEASE_NOTES" --newversion "$UPSTREAM_VERSION-0debian1-unstable1"
给我带来了一些麻烦,因为在 debian/changelog 中存在以下内容:
mkdotenv (0.2.0-0debian1-unstable1) unstable; urgency=medium
* * 1. Split codebase into multiple files. * 2. Use a seperate
version file and define built version upon compile. * 4. [BUGFIX]
If input file is same as output file copy input file into a
temporary one. * 5. Improved Documentation
-- Dimitrios Desyllas <[email protected]> Mon, 10 Mar 2025 20:08:00 +0200
该RELEASE_NOTES
文件包含:
1. Split codebase into multiple files.
2. Use a seperate version file and define built version upon compile.
4. [BUGFIX] If input file is same as output file copy input file into a temporary one.
5. Improved Documentation
您知道为什么所有行都卡在单个项目符号中吗?
dch
需要单个未修饰的变更日志条目。它将为您格式化,添加星号并根据需要换行。对于您的用例,您需要对每个条目运行一次,而无需指定目标发行版。然后,要“关闭”目标版本的条目,请运行
这需要一个参数但忽略它,因此有“忽略”参数。
-r
更新变更日志中的第一行以指定给出的分布-D
;-M
使用“维护者”字段中指定的名称和电子邮件地址,而debian/control
不是依赖环境变量。总体流程如下:
无需“初始化”新版本,当
dch
给定的版本与变更日志顶部的版本不匹配时,它会自动发生。最后正如@Stephen Kitt 所说:
为此,您需要通过调用以下命令来初始化版本:
然后对于文件中的每一行
RELEASE_NOTES
我们都需要调用:这会在文件上附加一行
debian/changelog
,然后我们完成该行:然后需要最终确定发布内容如下:
在您的示例中,这将导致以下变更日志条目:
2025/3/25 更新
如果没有导出环境变量,则会省略一些行
DEBEMAIL
,因此我为用户提供了一个小提示,让用户输入他/她的电子邮件并将其存储在 DEBEMAIL 文件中。