From 4fb98e759789da769689947b7c21cf8eb16d77a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o?= Date: Wed, 28 May 2025 17:27:09 +0100 Subject: [PATCH] chore: fix release script --- .github/scripts/create-platform-release-pr.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/scripts/create-platform-release-pr.sh b/.github/scripts/create-platform-release-pr.sh index 8d47e749..7f9ed294 100755 --- a/.github/scripts/create-platform-release-pr.sh +++ b/.github/scripts/create-platform-release-pr.sh @@ -24,6 +24,21 @@ if [[ -z $NEW_VERSION_NUMBER && $PLATFORM == "mobile" ]]; then exit 1 fi +############################################################################### +# Make a commit only when something is staged. Prevents git commit exit-1 when +# the version you’re bumping is already present on the branch. +############################################################################### +commit_if_needed () { + local msg="$1" + + # --cached = compare index to HEAD, not working tree + if git diff --cached --quiet; then + echo "Nothing to commit – skipping." + else + git commit -m "$msg" + fi +} + get_expected_changed_files() { local platform="$1" @@ -128,9 +143,9 @@ git add $changed_files # Generate a commit based on PLATFORM if [ "$PLATFORM" = "mobile" ]; then - git commit -m "bump semvar version to ${NEW_VERSION} && build version to ${NEW_VERSION_NUMBER}" + commit_if_needed "bump semvar version to ${NEW_VERSION} && build version to ${NEW_VERSION_NUMBER}" elif [ "$PLATFORM" = "extension" ]; then - git commit -m "bump semvar version to ${NEW_VERSION}" + commit_if_needed "bump semvar version to ${NEW_VERSION}" fi