Skip to content

Commit ead63f4

Browse files
jlecclaude
andcommitted
fix(release): route APP_VERSION update PRs to the correct branch
The script always targeted `-B master` regardless of version, so all 3.x update PRs landed on the 2.x branch (master) instead of main. They were rightly closed there, leaving APP_VERSION on main stuck. Changes: - 3.x draft versions (3.*) → branch from and PR to `main` - 2.x draft versions → branch from and PR to `master` (unchanged) - Add early exit when no draft release exists, preventing the script from running with an empty LATEST_DRAFT_VERSION and corrupting APP_VERSION with an empty string - Fix typo: LATET_DRAFT_VERSION → LATEST_DRAFT_VERSION in log message Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 9d1cec8 commit ead63f4

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

.github/scripts/update_app_version.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ APP_VERSION_FILE="APP_VERSION"
2222
LATEST_DRAFT_VERSION=$(gh release list -L 20 | awk -F '\t' '{if ($2 == "Draft" && match($3, "^[0-9]+\\.[0-9]+\\.[0-9]+")) {print $3; exit}}')
2323
LATEST_VERSION=$(gh release view --json tagName -q .tagName)
2424

25+
if [[ -z $LATEST_DRAFT_VERSION ]]; then
26+
echo "no draft release found, nothing to do"
27+
exit 0
28+
fi
29+
2530
if [[ $LATEST_DRAFT_VERSION == $LATEST_VERSION ]]; then
2631
echo "latest draft version ($LATEST_DRAFT_VERSION) matches latest version ($LATEST_VERSION)"
2732
exit 0
@@ -30,6 +35,14 @@ elif [[ $LATEST_DRAFT_VERSION == $(cat $APP_VERSION_FILE) ]]; then
3035
exit 0
3136
fi
3237

38+
# Route to the correct base branch:
39+
# 3.x releases live on `main`; 2.x releases live on `master`
40+
if [[ "$LATEST_DRAFT_VERSION" == 3.* ]]; then
41+
TARGET_BRANCH="main"
42+
else
43+
TARGET_BRANCH="master"
44+
fi
45+
3346
if [[ -n $GITHUB_ACTOR ]]; then
3447
git config --global user.name "${GITHUB_ACTOR}"
3548
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
@@ -42,13 +55,13 @@ BRANCH_NAME="$BRANCH_NAME_PREFIX-$LATEST_DRAFT_VERSION"
4255
EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME" || echo "false")
4356

4457
if [[ -n $EXISTS ]] && [[ $EXISTS != "false" ]]; then
45-
echo "A PR already exists on branch $BRANCH_NAME for App Version update: $LATET_DRAFT_VERSION"
58+
echo "A PR already exists on branch $BRANCH_NAME for App Version update: $LATEST_DRAFT_VERSION"
4659
exit 0
4760
fi
4861

49-
echo "checking out new Git branch $BRANCH_NAME..."
62+
echo "checking out new Git branch $BRANCH_NAME from $TARGET_BRANCH..."
5063

51-
git switch -c $BRANCH_NAME master
64+
git switch -c $BRANCH_NAME $TARGET_BRANCH
5265

5366
printf " done\n"
5467

@@ -70,7 +83,7 @@ git push -u origin $BRANCH_NAME
7083

7184
echo "Creating Pull Request..."
7285

73-
printf "This updates the App Version to $LATEST_DRAFT_VERSION" | gh pr create -R go-nv/goenv -B master \
86+
printf "This updates the App Version to $LATEST_DRAFT_VERSION" | gh pr create -R go-nv/goenv -B $TARGET_BRANCH \
7487
-t "$COMMIT_MSG" \
7588
-F -
7689

0 commit comments

Comments
 (0)