Resolve cargo publish --dry-run check failure

This commit is contained in:
jiangjianfeng
2024-10-14 09:18:23 +00:00
committed by Tate, Hongliang Tian
parent 3f1fa33b13
commit b269118c9a
2 changed files with 15 additions and 3 deletions

View File

@ -51,7 +51,19 @@ do_publish_for() {
TARGET_ARGS="--target $2"
fi
if [ -n "$DRY_RUN" ]; then
cargo publish --dry-run $TARGET_ARGS
# Temporarily change the crate version to the next patched version.
#
# `cargo publish --dry-run` requires that
# the crate version is not already published on crates.io,
# otherwise, the check will fail.
# Therefore, we modify the crate version to ensure it is not published.
current_version=$(cat $ASTER_SRC_DIR/VERSION)
next_patched_version=$(echo "$current_version" | awk -F. '{printf "%d.%d.%d\n", $1, $2, $3 + 1}')
pattern="^version = \"[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\"$"
sed -i "0,/${pattern}/s/${pattern}/version = \"${next_patched_version}\"/1" Cargo.toml
# Perform checks
cargo publish --dry-run --allow-dirty $TARGET_ARGS
cargo doc $TARGET_ARGS
else
cargo publish --token $TOKEN $TARGET_ARGS