Skip to content

Commit

Permalink
fix check-versioning-lib-release.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
plebhash committed Apr 2, 2024
1 parent e807209 commit 6376002
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions check-versioning-lib-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,36 @@ crates=$(find . -name Cargo.toml -exec dirname {} \; | sort)

# Filter out crates that are not published to crates.io
filter=("benches" "examples" "test" "roles")
for f in "${filter[@]}"; do
crates=$(echo "$crates" | grep -v "$f")
for crate in $crates; do
filtered=false
for f in "${filter[@]}"; do
if [ "$crate" = "./$f" ]; then
filtered=true
break
fi
done
if [ "$filtered" = false ]; then
filtered_crates+=("$crate")
fi
done

crates="${filtered_crates[@]}"

# Loop through each crate, while avoiding root workspace Cargo.toml and files under `target` directory
for crate in $crates; do
if [ "$crate" != "./protocols" ] && \
[ "$crate" != "./common" ] && \
[ "$crate" != "./roles" ] && \
[ "$crate" != "./utils" ] && \
! echo "$crate" | grep -q "target"; then

cd "$crate"

# Check if there were any changes between dev and main
git diff --quiet "dev" "main" -- .
git diff --quiet "origin/dev" "origin/main" -- .
if [ $? -ne 0 ]; then

# Check if crate versions on dev and main are identical
version_dev=$(git show dev:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}')
version_main=$(git show main:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}')
version_dev=$(git show origin/dev:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}')
version_main=$(git show origin/main:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}')
if [ "$version_dev" = "$version_main" ]; then
echo "Changes detected in crate $crate between dev and main branches! Versions on dev and main branches are identical ($version_dev), so you should bump the crate version on dev before merging into main."
exit 1
Expand Down

0 comments on commit 6376002

Please sign in to comment.