Skip to content

Commit

Permalink
v1.18: ci: improve version update script (backport of #1553) (#1591)
Browse files Browse the repository at this point in the history
ci: improve version update script (#1553)

* only apply related changes when bumping version

* ignore Cargo.toml if no match version

* fix shell check

* follow shellcheck SC2035

(cherry picked from commit 5ff7706)

Co-authored-by: Yihau Chen <[email protected]>
  • Loading branch information
2 people authored and willhickey committed Jun 8, 2024
1 parent 00dd1a7 commit e8335cf
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/increment-cargo-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ newVersion="$MAJOR.$MINOR.$PATCH$SPECIAL"

# Update all the Cargo.toml files
for Cargo_toml in "${Cargo_tomls[@]}"; do
# ignore when version inheritant from workspace (exclude programs/sbf/Cargo.toml)
if grep "^version = { workspace = true }" "$Cargo_toml" &>/dev/null && Cargo_toml && ! [[ $Cargo_toml =~ programs/sbf/Cargo.toml ]]; then
if ! grep "$currentVersion" "$Cargo_toml"; then
echo "$Cargo_toml (skipped)"
continue
fi

Expand All @@ -146,6 +146,16 @@ done
# Update cargo lock files
scripts/cargo-for-all-lock-files.sh tree >/dev/null

# Only apply related changes
(
shopt -s globstar
git diff --unified=0 ./**/Cargo.lock >cargo-lock-patch
grep -E '^(diff|index|---|\+\+\+|@@.*@@ name = .*|-version|\+version)' cargo-lock-patch >filtered-cargo-lock-patch
git checkout ./**/Cargo.lock
git apply --unidiff-zero filtered-cargo-lock-patch
rm cargo-lock-patch filtered-cargo-lock-patch
)

echo "$currentVersion -> $newVersion"

exit 0

0 comments on commit e8335cf

Please sign in to comment.