Skip to content

Commit 8d52874

Browse files
committed
refactor: Simplify Python script in publish workflow
This commit refactors the Python script used in the `publish-crate.yml` GitHub Actions workflow. Previously, a multi-line Python script embedded as a heredoc was used to parse the `cargo metadata` output and extract the crate's version. This has been replaced with a more concise single- line Python command executed using `python3 -c`. The change improves readability and reduces verbosity within the workflow definition file without altering the core functionality of version extraction and tag validation. Influence: 1. Verify the `publish-crate.yml` workflow still correctly extracts the crate version. 2. Ensure the tag validation step (`Tag ${tag} does not match crate version v${version}`) continues to function as expected. 3. Observe successful execution of the `check-tag` job in the CI pipeline for a new tag creation. refactor: 简化发布工作流中的 Python 脚本 此提交重构了 `publish-crate.yml` GitHub Actions 工作流中使用的 Python 脚本。之前,使用多行 Python 脚本(通过 heredoc 嵌入)来解析 `cargo metadata` 输出并提取 crate 的版本。现在已将其替换为使用 `python3 -c` 执 行的更简洁的单行 Python 命令。此更改提高了工作流定义文件的可读性并减少了 冗余,同时不改变版本提取和标签验证的核心功能。 Influence: 1. 验证 `publish-crate.yml` 工作流仍能正确提取 crate 版本。 2. 确保标签验证步骤(`Tag ${tag} does not match crate version v${version}`)继续按预期工作。 3. 观察 CI 管道中为新标签创建时 `check-tag` 作业的成功执行。
1 parent e5ede4d commit 8d52874

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

.github/workflows/publish-crate.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ jobs:
2727
run: |
2828
tag="${GITHUB_REF#refs/tags/}"
2929
version=$(cargo metadata --no-deps --format-version 1 |
30-
python3 - <<'PY'
31-
import json,sys
32-
meta=json.load(sys.stdin)
33-
print(meta['packages'][0]['version'])
34-
PY
35-
)
30+
python3 -c "import sys,json; print(json.load(sys.stdin)['packages'][0]['version'])")
3631
if [ "${tag}" != "v${version}" ]; then
3732
echo "Tag ${tag} does not match crate version v${version}" >&2
3833
exit 1

0 commit comments

Comments
 (0)