@@ -338,33 +338,50 @@ if ! $DRY_RUN; then
338338 if [[ " $AUTO_EXECUTE " =~ ^[Yy]$ ]]; then
339339 step " Executing Steps 🚀"
340340
341- execute " git commit -am \" Bump version to $NEW_VERSION \" " \
342- " Committing changes..." \
343- " Failed to commit changes. Please check your git status."
341+ # Check if there are changes to commit
342+ info " Checking git status..."
343+ if ! git diff --quiet HEAD -- " $CARGO_TOML " " Cargo.lock" ; then
344+ # There are changes to commit
345+ execute " git add $CARGO_TOML Cargo.lock" \
346+ " Staging changes..." \
347+ " Failed to stage changes."
348+
349+ if [ $? -eq 0 ]; then
350+ execute " git commit -m \" Bump version to $NEW_VERSION \" " \
351+ " Committing changes..." \
352+ " Failed to commit changes. Please check your git status."
353+ fi
354+ else
355+ warning " No changes detected in Cargo.toml or Cargo.lock. They might already be at version $NEW_VERSION ."
356+ info " Proceeding with tag creation anyway..."
357+ fi
344358
345- # Only proceed with tagging if commit was successful
346- if [ $? -eq 0 ]; then
359+ # Always try to create the tag, even if commit failed (might be using existing commit)
360+ # Check if tag already exists
361+ if git rev-parse " v$NEW_VERSION " > /dev/null 2>&1 ; then
362+ warning " Tag v$NEW_VERSION already exists! Skipping tag creation."
363+ else
347364 execute " git tag -a \" v$NEW_VERSION \" -m \" Release v$NEW_VERSION \" " \
348365 " Creating tag v$NEW_VERSION ..." \
349366 " Failed to create tag. Perhaps it already exists?"
367+ fi
368+
369+ # Only proceed with push if we have something to push (commit or tag)
370+ if [ $? -eq 0 ]; then
371+ # Confirm before pushing (this is a potentially risky operation)
372+ printf " ${YELLOW} Ready to push changes and tags to remote. Continue?${RESET} [y/N] "
373+ read -r CONFIRM_PUSH
350374
351- # Only proceed with push if tagging was successful
352- if [ $? -eq 0 ]; then
353- # Confirm before pushing (this is a potentially risky operation)
354- printf " ${YELLOW} Ready to push changes and tags to remote. Continue?${RESET} [y/N] "
355- read -r CONFIRM_PUSH
375+ if [[ " $CONFIRM_PUSH " =~ ^[Yy]$ ]]; then
376+ execute " git push && git push --tags" \
377+ " Pushing changes and tags..." \
378+ " Failed to push. Do you have upstream permissions?"
356379
357- if [[ " $CONFIRM_PUSH " =~ ^[Yy]$ ]]; then
358- execute " git push && git push --tags" \
359- " Pushing changes and tags..." \
360- " Failed to push. Do you have upstream permissions?"
361-
362- if [ $? -eq 0 ]; then
363- success " All steps completed successfully! 🎉"
364- fi
365- else
366- info " Skipping push operation. Changes are committed locally."
380+ if [ $? -eq 0 ]; then
381+ success " All steps completed successfully! 🎉"
367382 fi
383+ else
384+ info " Skipping push operation. Changes are committed locally."
368385 fi
369386 fi
370387 else
0 commit comments