From 950edfef14595e465e61450766726fc7938eba0e Mon Sep 17 00:00:00 2001 From: dsarno Date: Tue, 3 Feb 2026 09:37:03 -0800 Subject: [PATCH 1/3] fix: beta workflow no longer auto-bumps minor version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .github/workflows/beta-release.yml | 51 +++++++++--------- .github/workflows/release.yml | 86 +++++++++++++++++++++++------- 2 files changed, 94 insertions(+), 43 deletions(-) diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index eb2cdcf5a..655921cda 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -40,30 +40,30 @@ jobs: CURRENT_VERSION=$(jq -r '.version' MCPForUnity/package.json) echo "Current Unity package version: $CURRENT_VERSION" - # Strip any existing pre-release suffix for safe parsing - # e.g., "9.3.1-beta.1" -> "9.3.1" - BASE_VERSION=$(echo "$CURRENT_VERSION" | sed -E 's/-[a-zA-Z]+\.[0-9]+$//') - - # Validate we have a proper X.Y.Z format before arithmetic - if ! [[ "$BASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: Could not parse version '$CURRENT_VERSION' -> '$BASE_VERSION'" >&2 - exit 1 - fi - - # Check if already a beta version - if [[ "$CURRENT_VERSION" == *"-beta."* ]]; then - echo "Already a beta version, keeping: $CURRENT_VERSION" - echo "unity_beta_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" + # Check if already a beta version - increment beta number + if [[ "$CURRENT_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)-beta\.([0-9]+)$ ]]; then + BASE_VERSION="${BASH_REMATCH[1]}" + BETA_NUM="${BASH_REMATCH[2]}" + NEXT_BETA=$((BETA_NUM + 1)) + BETA_VERSION="${BASE_VERSION}-beta.${NEXT_BETA}" + echo "Incrementing beta number: $CURRENT_VERSION -> $BETA_VERSION" + echo "unity_beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT" echo "already_beta=true" >> "$GITHUB_OUTPUT" - else - # Create beta version with semver format (e.g., 9.4.0-beta.1) - # Bump minor version to ensure beta is "newer" than stable - IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION" - NEXT_MINOR=$((MINOR + 1)) - BETA_VERSION="${MAJOR}.${NEXT_MINOR}.0-beta.1" - echo "Generated Unity beta version: $BETA_VERSION" + elif [[ "$CURRENT_VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + # Stable version - bump patch and add -beta.1 suffix + # This ensures beta is "newer" than stable (9.3.2-beta.1 > 9.3.1) + # The release workflow decides final bump type (patch/minor/major) + MAJOR="${BASH_REMATCH[1]}" + MINOR="${BASH_REMATCH[2]}" + PATCH="${BASH_REMATCH[3]}" + NEXT_PATCH=$((PATCH + 1)) + BETA_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-beta.1" + echo "Converting stable to beta: $CURRENT_VERSION -> $BETA_VERSION" echo "unity_beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT" echo "already_beta=false" >> "$GITHUB_OUTPUT" + else + echo "Error: Could not parse version '$CURRENT_VERSION'" >&2 + exit 1 fi - name: Update Unity package.json with beta version @@ -157,12 +157,13 @@ jobs: echo "Error: Could not parse version '$RAW_VERSION' -> '$BASE_VERSION'" >&2 exit 1 fi - # Bump minor version and use beta suffix (PEP 440 compliant: X.Y+1.0bN) - # This ensures beta is "newer" than the stable release + # Bump patch and add beta suffix (PEP 440 compliant: X.Y.Z+1bN) + # This ensures beta is "newer" than stable (9.3.2b1 > 9.3.1) + # The release workflow decides final bump type (patch/minor/major) IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION" - NEXT_MINOR=$((MINOR + 1)) + NEXT_PATCH=$((PATCH + 1)) BETA_NUMBER="$(date +%Y%m%d%H%M%S)" - BETA_VERSION="${MAJOR}.${NEXT_MINOR}.0b${BETA_NUMBER}" + BETA_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}b${BETA_NUMBER}" echo "Raw version: $RAW_VERSION" echo "Base version: $BASE_VERSION" echo "Beta version: $BETA_VERSION" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0b92a1e6..947b02772 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,12 +8,13 @@ on: workflow_dispatch: inputs: version_bump: - description: "Version bump type" + description: "Version bump type (none = release beta version as-is)" type: choice options: - patch - minor - major + - none default: patch required: true @@ -44,6 +45,50 @@ jobs: ref: main fetch-depth: 0 + - name: Show current versions + shell: bash + run: | + set -euo pipefail + echo "============================================" + echo "CURRENT VERSION STATUS" + echo "============================================" + + # Get main version + MAIN_VERSION=$(jq -r '.version' "MCPForUnity/package.json") + MAIN_PYPI=$(grep -oP '(?<=version = ")[^"]+' Server/pyproject.toml) + echo "Main branch:" + echo " Unity package: $MAIN_VERSION" + echo " PyPI server: $MAIN_PYPI" + echo "" + + # Get beta version + git fetch origin beta + BETA_VERSION=$(git show origin/beta:MCPForUnity/package.json | jq -r '.version') + BETA_PYPI=$(git show origin/beta:Server/pyproject.toml | grep -oP '(?<=version = ")[^"]+') + echo "Beta branch:" + echo " Unity package: $BETA_VERSION" + echo " PyPI server: $BETA_PYPI" + echo "" + + # Show what will happen + BUMP="${{ inputs.version_bump }}" + STRIPPED=$(echo "$BETA_VERSION" | sed -E 's/-[a-zA-Z]+\.[0-9]+$//') + echo "Selected bump type: $BUMP" + echo "After stripping beta suffix: $STRIPPED" + + if [[ "$BUMP" == "none" ]]; then + echo "Release version will be: $STRIPPED" + else + IFS='.' read -r MA MI PA <<< "$STRIPPED" + case "$BUMP" in + major) ((MA+=1)); MI=0; PA=0 ;; + minor) ((MI+=1)); PA=0 ;; + patch) ((PA+=1)) ;; + esac + echo "Release version will be: $MA.$MI.$PA" + fi + echo "============================================" + - name: Merge beta into main shell: bash run: | @@ -97,24 +142,29 @@ jobs: CURRENT_VERSION=$(jq -r '.version' "MCPForUnity/package.json") echo "Current version: $CURRENT_VERSION" - IFS='.' read -r MA MI PA <<< "$CURRENT_VERSION" - case "$BUMP" in - major) - ((MA+=1)); MI=0; PA=0 - ;; - minor) - ((MI+=1)); PA=0 - ;; - patch) - ((PA+=1)) - ;; - *) - echo "Unknown version_bump: $BUMP" >&2 - exit 1 - ;; - esac + if [[ "$BUMP" == "none" ]]; then + # Release the current version as-is (after beta suffix was stripped) + NEW_VERSION="$CURRENT_VERSION" + else + IFS='.' read -r MA MI PA <<< "$CURRENT_VERSION" + case "$BUMP" in + major) + ((MA+=1)); MI=0; PA=0 + ;; + minor) + ((MI+=1)); PA=0 + ;; + patch) + ((PA+=1)) + ;; + *) + echo "Unknown version_bump: $BUMP" >&2 + exit 1 + ;; + esac + NEW_VERSION="$MA.$MI.$PA" + fi - NEW_VERSION="$MA.$MI.$PA" echo "New version: $NEW_VERSION" echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" From 6fe2661f1bd33f66aacddccf7efe2b390a41cdb9 Mon Sep 17 00:00:00 2001 From: dsarno Date: Tue, 3 Feb 2026 09:41:31 -0800 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20remove=20redundant=20=CE=B2=20char?= =?UTF-8?q?acter=20from=20version=20badge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The version string now includes "-beta.N" suffix, making the separate β indicator redundant. Co-Authored-By: Claude Opus 4.5 --- MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs b/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs index a626a5278..46e21757d 100644 --- a/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs +++ b/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs @@ -327,7 +327,7 @@ private void UpdateVersionLabel(bool useBetaServer) } string version = AssetPathUtility.GetPackageVersion(); - versionLabel.text = useBetaServer ? $"v{version} β" : $"v{version}"; + versionLabel.text = $"v{version}"; versionLabel.tooltip = useBetaServer ? "Beta server mode - fetching pre-release server versions from PyPI" : $"MCP For Unity v{version}"; From 62092ca543e9142a25b29eb6c92c0861da5148c6 Mon Sep 17 00:00:00 2001 From: dsarno Date: Tue, 3 Feb 2026 09:48:01 -0800 Subject: [PATCH 3/3] 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 --- .github/workflows/beta-release.yml | 53 ++++++++++++++++++++++-------- .github/workflows/release.yml | 18 ++++++++-- 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index 655921cda..fc9a1328f 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -47,8 +47,6 @@ jobs: NEXT_BETA=$((BETA_NUM + 1)) BETA_VERSION="${BASE_VERSION}-beta.${NEXT_BETA}" echo "Incrementing beta number: $CURRENT_VERSION -> $BETA_VERSION" - echo "unity_beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT" - echo "already_beta=true" >> "$GITHUB_OUTPUT" elif [[ "$CURRENT_VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then # Stable version - bump patch and add -beta.1 suffix # This ensures beta is "newer" than stable (9.3.2-beta.1 > 9.3.1) @@ -59,15 +57,25 @@ jobs: NEXT_PATCH=$((PATCH + 1)) BETA_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-beta.1" echo "Converting stable to beta: $CURRENT_VERSION -> $BETA_VERSION" - echo "unity_beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT" - echo "already_beta=false" >> "$GITHUB_OUTPUT" else echo "Error: Could not parse version '$CURRENT_VERSION'" >&2 exit 1 fi + # Always output the computed version + echo "unity_beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT" + + # Only skip update if computed version matches current (no change needed) + if [[ "$BETA_VERSION" == "$CURRENT_VERSION" ]]; then + echo "Version unchanged, skipping update" + echo "needs_update=false" >> "$GITHUB_OUTPUT" + else + echo "Version will be updated: $CURRENT_VERSION -> $BETA_VERSION" + echo "needs_update=true" >> "$GITHUB_OUTPUT" + fi + - name: Update Unity package.json with beta version - if: steps.version.outputs.already_beta != 'true' + if: steps.version.outputs.needs_update == 'true' env: BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }} shell: bash @@ -81,7 +89,7 @@ jobs: - name: Commit to temporary branch and create PR id: commit - if: steps.version.outputs.already_beta != 'true' + if: steps.version.outputs.needs_update == 'true' env: GH_TOKEN: ${{ github.token }} BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }} @@ -149,22 +157,39 @@ jobs: run: | set -euo pipefail RAW_VERSION=$(grep -oP '(?<=version = ")[^"]+' Server/pyproject.toml) - # Strip any existing pre-release suffix (a, b, rc, dev, post) for safe parsing - # e.g., "9.2.0b1" -> "9.2.0", "9.2.0.dev1" -> "9.2.0" - BASE_VERSION=$(echo "$RAW_VERSION" | sed -E 's/(a|b|rc|\.dev|\.post)[0-9]+$//') + echo "Raw version: $RAW_VERSION" + + # Check if already a beta/prerelease version + if [[ "$RAW_VERSION" =~ (a|b|rc|\.dev|\.post)[0-9]+$ ]]; then + IS_PRERELEASE=true + # Strip the prerelease suffix to get base version + BASE_VERSION=$(echo "$RAW_VERSION" | sed -E 's/(a|b|rc|\.dev|\.post)[0-9]+$//') + else + IS_PRERELEASE=false + BASE_VERSION="$RAW_VERSION" + fi + # Validate we have a proper X.Y.Z format if ! [[ "$BASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "Error: Could not parse version '$RAW_VERSION' -> '$BASE_VERSION'" >&2 exit 1 fi - # Bump patch and add beta suffix (PEP 440 compliant: X.Y.Z+1bN) - # This ensures beta is "newer" than stable (9.3.2b1 > 9.3.1) - # The release workflow decides final bump type (patch/minor/major) + IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION" - NEXT_PATCH=$((PATCH + 1)) + + # Only bump patch if coming from stable; keep same base if already prerelease + if [[ "$IS_PRERELEASE" == "true" ]]; then + # Already on a beta series - keep the same base version + NEXT_PATCH="$PATCH" + echo "Already prerelease, keeping base: $BASE_VERSION" + else + # Stable version - bump patch to ensure beta is "newer" + NEXT_PATCH=$((PATCH + 1)) + echo "Stable version, bumping patch: $PATCH -> $NEXT_PATCH" + fi + BETA_NUMBER="$(date +%Y%m%d%H%M%S)" BETA_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}b${BETA_NUMBER}" - echo "Raw version: $RAW_VERSION" echo "Base version: $BASE_VERSION" echo "Beta version: $BETA_VERSION" echo "beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 947b02772..33e377348 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,6 +46,7 @@ jobs: fetch-depth: 0 - name: Show current versions + id: preview shell: bash run: | set -euo pipefail @@ -70,9 +71,12 @@ jobs: echo " PyPI server: $BETA_PYPI" echo "" + # Compute stripped version (used for "none" bump option) + STRIPPED=$(echo "$BETA_VERSION" | sed -E 's/-[a-zA-Z]+\.[0-9]+$//') + echo "stripped_version=$STRIPPED" >> "$GITHUB_OUTPUT" + # Show what will happen BUMP="${{ inputs.version_bump }}" - STRIPPED=$(echo "$BETA_VERSION" | sed -E 's/-[a-zA-Z]+\.[0-9]+$//') echo "Selected bump type: $BUMP" echo "After stripping beta suffix: $STRIPPED" @@ -135,6 +139,8 @@ jobs: - name: Compute new version id: compute + env: + PREVIEWED_STRIPPED: ${{ steps.preview.outputs.stripped_version }} shell: bash run: | set -euo pipefail @@ -142,9 +148,15 @@ jobs: CURRENT_VERSION=$(jq -r '.version' "MCPForUnity/package.json") echo "Current version: $CURRENT_VERSION" + # Sanity check: ensure current version matches what was previewed + if [[ "$CURRENT_VERSION" != "$PREVIEWED_STRIPPED" ]]; then + echo "Warning: Current version ($CURRENT_VERSION) differs from previewed ($PREVIEWED_STRIPPED)" + echo "This may indicate an unexpected merge result. Proceeding with current version." + fi + if [[ "$BUMP" == "none" ]]; then - # Release the current version as-is (after beta suffix was stripped) - NEW_VERSION="$CURRENT_VERSION" + # Use the previewed stripped version to ensure consistency with what user saw + NEW_VERSION="$PREVIEWED_STRIPPED" else IFS='.' read -r MA MI PA <<< "$CURRENT_VERSION" case "$BUMP" in