Skip to content

Commit 7aa539c

Browse files
dsarnoclaude
andauthored
fix: beta workflow no longer auto-bumps minor version (#673)
* fix: beta workflow no longer auto-bumps minor version Changes to beta-release.yml: - Beta now bumps patch instead of minor (9.3.1 → 9.3.2-beta.1) - Allows patch releases without being forced into minor bumps - Increment beta number if already a beta version Changes to release.yml: - Added "none" bump option to release beta version as-is - Added version status display showing main/beta versions and what the release version will be Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove redundant β character from version badge The version string now includes "-beta.N" suffix, making the separate β indicator redundant. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: improve version consistency in release workflows beta-release.yml: - Changed from already_beta to needs_update flag - Only skip updates when computed version matches current - PyPI versioning now detects existing prereleases and keeps the same base version instead of always bumping patch release.yml: - Preview step outputs stripped_version to GITHUB_OUTPUT - Compute step uses previewed value for "none" bump option - Added sanity check warning if versions diverge unexpectedly This ensures the released version matches what was shown to the user and prevents unnecessary patch bumps on consecutive beta runs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 20e822b commit 7aa539c

File tree

3 files changed

+137
-49
lines changed

3 files changed

+137
-49
lines changed

.github/workflows/beta-release.yml

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,34 +40,42 @@ jobs:
4040
CURRENT_VERSION=$(jq -r '.version' MCPForUnity/package.json)
4141
echo "Current Unity package version: $CURRENT_VERSION"
4242
43-
# Strip any existing pre-release suffix for safe parsing
44-
# e.g., "9.3.1-beta.1" -> "9.3.1"
45-
BASE_VERSION=$(echo "$CURRENT_VERSION" | sed -E 's/-[a-zA-Z]+\.[0-9]+$//')
46-
47-
# Validate we have a proper X.Y.Z format before arithmetic
48-
if ! [[ "$BASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
49-
echo "Error: Could not parse version '$CURRENT_VERSION' -> '$BASE_VERSION'" >&2
43+
# Check if already a beta version - increment beta number
44+
if [[ "$CURRENT_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)-beta\.([0-9]+)$ ]]; then
45+
BASE_VERSION="${BASH_REMATCH[1]}"
46+
BETA_NUM="${BASH_REMATCH[2]}"
47+
NEXT_BETA=$((BETA_NUM + 1))
48+
BETA_VERSION="${BASE_VERSION}-beta.${NEXT_BETA}"
49+
echo "Incrementing beta number: $CURRENT_VERSION -> $BETA_VERSION"
50+
elif [[ "$CURRENT_VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
51+
# Stable version - bump patch and add -beta.1 suffix
52+
# This ensures beta is "newer" than stable (9.3.2-beta.1 > 9.3.1)
53+
# The release workflow decides final bump type (patch/minor/major)
54+
MAJOR="${BASH_REMATCH[1]}"
55+
MINOR="${BASH_REMATCH[2]}"
56+
PATCH="${BASH_REMATCH[3]}"
57+
NEXT_PATCH=$((PATCH + 1))
58+
BETA_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-beta.1"
59+
echo "Converting stable to beta: $CURRENT_VERSION -> $BETA_VERSION"
60+
else
61+
echo "Error: Could not parse version '$CURRENT_VERSION'" >&2
5062
exit 1
5163
fi
5264
53-
# Check if already a beta version
54-
if [[ "$CURRENT_VERSION" == *"-beta."* ]]; then
55-
echo "Already a beta version, keeping: $CURRENT_VERSION"
56-
echo "unity_beta_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
57-
echo "already_beta=true" >> "$GITHUB_OUTPUT"
65+
# Always output the computed version
66+
echo "unity_beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT"
67+
68+
# Only skip update if computed version matches current (no change needed)
69+
if [[ "$BETA_VERSION" == "$CURRENT_VERSION" ]]; then
70+
echo "Version unchanged, skipping update"
71+
echo "needs_update=false" >> "$GITHUB_OUTPUT"
5872
else
59-
# Create beta version with semver format (e.g., 9.4.0-beta.1)
60-
# Bump minor version to ensure beta is "newer" than stable
61-
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
62-
NEXT_MINOR=$((MINOR + 1))
63-
BETA_VERSION="${MAJOR}.${NEXT_MINOR}.0-beta.1"
64-
echo "Generated Unity beta version: $BETA_VERSION"
65-
echo "unity_beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT"
66-
echo "already_beta=false" >> "$GITHUB_OUTPUT"
73+
echo "Version will be updated: $CURRENT_VERSION -> $BETA_VERSION"
74+
echo "needs_update=true" >> "$GITHUB_OUTPUT"
6775
fi
6876
6977
- name: Update Unity package.json with beta version
70-
if: steps.version.outputs.already_beta != 'true'
78+
if: steps.version.outputs.needs_update == 'true'
7179
env:
7280
BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }}
7381
shell: bash
@@ -81,7 +89,7 @@ jobs:
8189
8290
- name: Commit to temporary branch and create PR
8391
id: commit
84-
if: steps.version.outputs.already_beta != 'true'
92+
if: steps.version.outputs.needs_update == 'true'
8593
env:
8694
GH_TOKEN: ${{ github.token }}
8795
BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }}
@@ -149,21 +157,39 @@ jobs:
149157
run: |
150158
set -euo pipefail
151159
RAW_VERSION=$(grep -oP '(?<=version = ")[^"]+' Server/pyproject.toml)
152-
# Strip any existing pre-release suffix (a, b, rc, dev, post) for safe parsing
153-
# e.g., "9.2.0b1" -> "9.2.0", "9.2.0.dev1" -> "9.2.0"
154-
BASE_VERSION=$(echo "$RAW_VERSION" | sed -E 's/(a|b|rc|\.dev|\.post)[0-9]+$//')
160+
echo "Raw version: $RAW_VERSION"
161+
162+
# Check if already a beta/prerelease version
163+
if [[ "$RAW_VERSION" =~ (a|b|rc|\.dev|\.post)[0-9]+$ ]]; then
164+
IS_PRERELEASE=true
165+
# Strip the prerelease suffix to get base version
166+
BASE_VERSION=$(echo "$RAW_VERSION" | sed -E 's/(a|b|rc|\.dev|\.post)[0-9]+$//')
167+
else
168+
IS_PRERELEASE=false
169+
BASE_VERSION="$RAW_VERSION"
170+
fi
171+
155172
# Validate we have a proper X.Y.Z format
156173
if ! [[ "$BASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
157174
echo "Error: Could not parse version '$RAW_VERSION' -> '$BASE_VERSION'" >&2
158175
exit 1
159176
fi
160-
# Bump minor version and use beta suffix (PEP 440 compliant: X.Y+1.0bN)
161-
# This ensures beta is "newer" than the stable release
177+
162178
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
163-
NEXT_MINOR=$((MINOR + 1))
179+
180+
# Only bump patch if coming from stable; keep same base if already prerelease
181+
if [[ "$IS_PRERELEASE" == "true" ]]; then
182+
# Already on a beta series - keep the same base version
183+
NEXT_PATCH="$PATCH"
184+
echo "Already prerelease, keeping base: $BASE_VERSION"
185+
else
186+
# Stable version - bump patch to ensure beta is "newer"
187+
NEXT_PATCH=$((PATCH + 1))
188+
echo "Stable version, bumping patch: $PATCH -> $NEXT_PATCH"
189+
fi
190+
164191
BETA_NUMBER="$(date +%Y%m%d%H%M%S)"
165-
BETA_VERSION="${MAJOR}.${NEXT_MINOR}.0b${BETA_NUMBER}"
166-
echo "Raw version: $RAW_VERSION"
192+
BETA_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}b${BETA_NUMBER}"
167193
echo "Base version: $BASE_VERSION"
168194
echo "Beta version: $BETA_VERSION"
169195
echo "beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT"

.github/workflows/release.yml

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ on:
88
workflow_dispatch:
99
inputs:
1010
version_bump:
11-
description: "Version bump type"
11+
description: "Version bump type (none = release beta version as-is)"
1212
type: choice
1313
options:
1414
- patch
1515
- minor
1616
- major
17+
- none
1718
default: patch
1819
required: true
1920

@@ -44,6 +45,54 @@ jobs:
4445
ref: main
4546
fetch-depth: 0
4647

48+
- name: Show current versions
49+
id: preview
50+
shell: bash
51+
run: |
52+
set -euo pipefail
53+
echo "============================================"
54+
echo "CURRENT VERSION STATUS"
55+
echo "============================================"
56+
57+
# Get main version
58+
MAIN_VERSION=$(jq -r '.version' "MCPForUnity/package.json")
59+
MAIN_PYPI=$(grep -oP '(?<=version = ")[^"]+' Server/pyproject.toml)
60+
echo "Main branch:"
61+
echo " Unity package: $MAIN_VERSION"
62+
echo " PyPI server: $MAIN_PYPI"
63+
echo ""
64+
65+
# Get beta version
66+
git fetch origin beta
67+
BETA_VERSION=$(git show origin/beta:MCPForUnity/package.json | jq -r '.version')
68+
BETA_PYPI=$(git show origin/beta:Server/pyproject.toml | grep -oP '(?<=version = ")[^"]+')
69+
echo "Beta branch:"
70+
echo " Unity package: $BETA_VERSION"
71+
echo " PyPI server: $BETA_PYPI"
72+
echo ""
73+
74+
# Compute stripped version (used for "none" bump option)
75+
STRIPPED=$(echo "$BETA_VERSION" | sed -E 's/-[a-zA-Z]+\.[0-9]+$//')
76+
echo "stripped_version=$STRIPPED" >> "$GITHUB_OUTPUT"
77+
78+
# Show what will happen
79+
BUMP="${{ inputs.version_bump }}"
80+
echo "Selected bump type: $BUMP"
81+
echo "After stripping beta suffix: $STRIPPED"
82+
83+
if [[ "$BUMP" == "none" ]]; then
84+
echo "Release version will be: $STRIPPED"
85+
else
86+
IFS='.' read -r MA MI PA <<< "$STRIPPED"
87+
case "$BUMP" in
88+
major) ((MA+=1)); MI=0; PA=0 ;;
89+
minor) ((MI+=1)); PA=0 ;;
90+
patch) ((PA+=1)) ;;
91+
esac
92+
echo "Release version will be: $MA.$MI.$PA"
93+
fi
94+
echo "============================================"
95+
4796
- name: Merge beta into main
4897
shell: bash
4998
run: |
@@ -90,31 +139,44 @@ jobs:
90139
91140
- name: Compute new version
92141
id: compute
142+
env:
143+
PREVIEWED_STRIPPED: ${{ steps.preview.outputs.stripped_version }}
93144
shell: bash
94145
run: |
95146
set -euo pipefail
96147
BUMP="${{ inputs.version_bump }}"
97148
CURRENT_VERSION=$(jq -r '.version' "MCPForUnity/package.json")
98149
echo "Current version: $CURRENT_VERSION"
99150
100-
IFS='.' read -r MA MI PA <<< "$CURRENT_VERSION"
101-
case "$BUMP" in
102-
major)
103-
((MA+=1)); MI=0; PA=0
104-
;;
105-
minor)
106-
((MI+=1)); PA=0
107-
;;
108-
patch)
109-
((PA+=1))
110-
;;
111-
*)
112-
echo "Unknown version_bump: $BUMP" >&2
113-
exit 1
114-
;;
115-
esac
151+
# Sanity check: ensure current version matches what was previewed
152+
if [[ "$CURRENT_VERSION" != "$PREVIEWED_STRIPPED" ]]; then
153+
echo "Warning: Current version ($CURRENT_VERSION) differs from previewed ($PREVIEWED_STRIPPED)"
154+
echo "This may indicate an unexpected merge result. Proceeding with current version."
155+
fi
156+
157+
if [[ "$BUMP" == "none" ]]; then
158+
# Use the previewed stripped version to ensure consistency with what user saw
159+
NEW_VERSION="$PREVIEWED_STRIPPED"
160+
else
161+
IFS='.' read -r MA MI PA <<< "$CURRENT_VERSION"
162+
case "$BUMP" in
163+
major)
164+
((MA+=1)); MI=0; PA=0
165+
;;
166+
minor)
167+
((MI+=1)); PA=0
168+
;;
169+
patch)
170+
((PA+=1))
171+
;;
172+
*)
173+
echo "Unknown version_bump: $BUMP" >&2
174+
exit 1
175+
;;
176+
esac
177+
NEW_VERSION="$MA.$MI.$PA"
178+
fi
116179
117-
NEW_VERSION="$MA.$MI.$PA"
118180
echo "New version: $NEW_VERSION"
119181
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
120182
echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"

MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private void UpdateVersionLabel(bool useBetaServer)
327327
}
328328

329329
string version = AssetPathUtility.GetPackageVersion();
330-
versionLabel.text = useBetaServer ? $"v{version} β" : $"v{version}";
330+
versionLabel.text = $"v{version}";
331331
versionLabel.tooltip = useBetaServer
332332
? "Beta server mode - fetching pre-release server versions from PyPI"
333333
: $"MCP For Unity v{version}";

0 commit comments

Comments
 (0)