Skip to content

Commit aa9269b

Browse files
jbachorikclaude
andcommitted
fix(release): pre-increment patch version when already tagged
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 0114dbc commit aa9269b

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

.github/scripts/release.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ if [ "$TYPE" == "PATCH" ]; then
6060
echo "Patch release can be created only for 'release/*' branch."
6161
exit 1
6262
fi
63+
# First patch after a minor/major release: the current version is already tagged.
64+
# Pre-increment the patch so we tag the next version (e.g. 1.40.0 -> 1.40.1).
65+
if git rev-parse "v_${BASE}" >/dev/null 2>&1; then
66+
if [ -z "$DRYRUN" ]; then
67+
./gradlew incrementVersion --versionIncrementType=PATCH
68+
BASE=$(./gradlew printVersion -Psnapshot=false | grep 'Version:' | cut -f2 -d' ')
69+
else
70+
echo "[DRY-RUN] Version $BASE is already tagged; would pre-increment patch before tagging"
71+
fi
72+
fi
6373
RELEASE_BRANCH="release/${BASE%.*}._"
6474
create_annotated_tag "$BASE" "$TYPE" "$BRANCH"
6575
fi

.github/workflows/release-validated.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,14 @@ jobs:
105105
RELEASE_VERSION="$BASE"
106106
fi
107107
else
108-
# PATCH always increments
109-
RELEASE_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
108+
# PATCH: increment only when the current version is already tagged
109+
# (first patch after a minor/major release); subsequent patches start
110+
# from the already-bumped dev version in build.gradle.kts.
111+
if [ "$ALREADY_RELEASED" == "true" ]; then
112+
RELEASE_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
113+
else
114+
RELEASE_VERSION="$BASE"
115+
fi
110116
fi
111117
112118
# Compute release branch

0 commit comments

Comments
 (0)