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>beta
parent
20e822b60f
commit
7aa539c9fe
|
|
@ -40,34 +40,42 @@ jobs:
|
||||||
CURRENT_VERSION=$(jq -r '.version' MCPForUnity/package.json)
|
CURRENT_VERSION=$(jq -r '.version' MCPForUnity/package.json)
|
||||||
echo "Current Unity package version: $CURRENT_VERSION"
|
echo "Current Unity package version: $CURRENT_VERSION"
|
||||||
|
|
||||||
# Strip any existing pre-release suffix for safe parsing
|
# Check if already a beta version - increment beta number
|
||||||
# e.g., "9.3.1-beta.1" -> "9.3.1"
|
if [[ "$CURRENT_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)-beta\.([0-9]+)$ ]]; then
|
||||||
BASE_VERSION=$(echo "$CURRENT_VERSION" | sed -E 's/-[a-zA-Z]+\.[0-9]+$//')
|
BASE_VERSION="${BASH_REMATCH[1]}"
|
||||||
|
BETA_NUM="${BASH_REMATCH[2]}"
|
||||||
# Validate we have a proper X.Y.Z format before arithmetic
|
NEXT_BETA=$((BETA_NUM + 1))
|
||||||
if ! [[ "$BASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
BETA_VERSION="${BASE_VERSION}-beta.${NEXT_BETA}"
|
||||||
echo "Error: Could not parse version '$CURRENT_VERSION' -> '$BASE_VERSION'" >&2
|
echo "Incrementing beta number: $CURRENT_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"
|
||||||
|
else
|
||||||
|
echo "Error: Could not parse version '$CURRENT_VERSION'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if already a beta version
|
# Always output the computed version
|
||||||
if [[ "$CURRENT_VERSION" == *"-beta."* ]]; then
|
|
||||||
echo "Already a beta version, keeping: $CURRENT_VERSION"
|
|
||||||
echo "unity_beta_version=$CURRENT_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"
|
|
||||||
echo "unity_beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT"
|
echo "unity_beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT"
|
||||||
echo "already_beta=false" >> "$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
|
fi
|
||||||
|
|
||||||
- name: Update Unity package.json with beta version
|
- name: Update Unity package.json with beta version
|
||||||
if: steps.version.outputs.already_beta != 'true'
|
if: steps.version.outputs.needs_update == 'true'
|
||||||
env:
|
env:
|
||||||
BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }}
|
BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
@ -81,7 +89,7 @@ jobs:
|
||||||
|
|
||||||
- name: Commit to temporary branch and create PR
|
- name: Commit to temporary branch and create PR
|
||||||
id: commit
|
id: commit
|
||||||
if: steps.version.outputs.already_beta != 'true'
|
if: steps.version.outputs.needs_update == 'true'
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }}
|
BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }}
|
||||||
|
|
@ -149,21 +157,39 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
RAW_VERSION=$(grep -oP '(?<=version = ")[^"]+' Server/pyproject.toml)
|
RAW_VERSION=$(grep -oP '(?<=version = ")[^"]+' Server/pyproject.toml)
|
||||||
# Strip any existing pre-release suffix (a, b, rc, dev, post) for safe parsing
|
echo "Raw version: $RAW_VERSION"
|
||||||
# e.g., "9.2.0b1" -> "9.2.0", "9.2.0.dev1" -> "9.2.0"
|
|
||||||
|
# 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]+$//')
|
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
|
# Validate we have a proper X.Y.Z format
|
||||||
if ! [[ "$BASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
if ! [[ "$BASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
echo "Error: Could not parse version '$RAW_VERSION' -> '$BASE_VERSION'" >&2
|
echo "Error: Could not parse version '$RAW_VERSION' -> '$BASE_VERSION'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Bump minor version and use beta suffix (PEP 440 compliant: X.Y+1.0bN)
|
|
||||||
# This ensures beta is "newer" than the stable release
|
|
||||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
|
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
|
||||||
NEXT_MINOR=$((MINOR + 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_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 "Base version: $BASE_VERSION"
|
||||||
echo "Beta version: $BETA_VERSION"
|
echo "Beta version: $BETA_VERSION"
|
||||||
echo "beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT"
|
echo "beta_version=$BETA_VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,13 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
version_bump:
|
version_bump:
|
||||||
description: "Version bump type"
|
description: "Version bump type (none = release beta version as-is)"
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- patch
|
- patch
|
||||||
- minor
|
- minor
|
||||||
- major
|
- major
|
||||||
|
- none
|
||||||
default: patch
|
default: patch
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
|
@ -44,6 +45,54 @@ jobs:
|
||||||
ref: main
|
ref: main
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Show current versions
|
||||||
|
id: preview
|
||||||
|
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 ""
|
||||||
|
|
||||||
|
# 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 }}"
|
||||||
|
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
|
- name: Merge beta into main
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -90,6 +139,8 @@ jobs:
|
||||||
|
|
||||||
- name: Compute new version
|
- name: Compute new version
|
||||||
id: compute
|
id: compute
|
||||||
|
env:
|
||||||
|
PREVIEWED_STRIPPED: ${{ steps.preview.outputs.stripped_version }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
@ -97,6 +148,16 @@ jobs:
|
||||||
CURRENT_VERSION=$(jq -r '.version' "MCPForUnity/package.json")
|
CURRENT_VERSION=$(jq -r '.version' "MCPForUnity/package.json")
|
||||||
echo "Current version: $CURRENT_VERSION"
|
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
|
||||||
|
# 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"
|
IFS='.' read -r MA MI PA <<< "$CURRENT_VERSION"
|
||||||
case "$BUMP" in
|
case "$BUMP" in
|
||||||
major)
|
major)
|
||||||
|
|
@ -113,8 +174,9 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
NEW_VERSION="$MA.$MI.$PA"
|
NEW_VERSION="$MA.$MI.$PA"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "New version: $NEW_VERSION"
|
echo "New version: $NEW_VERSION"
|
||||||
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||||
echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
|
echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
|
||||||
|
|
@ -327,7 +327,7 @@ namespace MCPForUnity.Editor.Windows
|
||||||
}
|
}
|
||||||
|
|
||||||
string version = AssetPathUtility.GetPackageVersion();
|
string version = AssetPathUtility.GetPackageVersion();
|
||||||
versionLabel.text = useBetaServer ? $"v{version} β" : $"v{version}";
|
versionLabel.text = $"v{version}";
|
||||||
versionLabel.tooltip = useBetaServer
|
versionLabel.tooltip = useBetaServer
|
||||||
? "Beta server mode - fetching pre-release server versions from PyPI"
|
? "Beta server mode - fetching pre-release server versions from PyPI"
|
||||||
: $"MCP For Unity v{version}";
|
: $"MCP For Unity v{version}";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue