fix: use PR-based approach for beta version updates

- Replace direct push with PR creation to bypass branch protection rules
- Add bot check to both jobs to prevent loops and double-publish
- Remove needs dependency so PyPI publish runs in parallel
- Simplify by not auto-merging the version PR

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
beta
dsarno 2026-02-02 18:49:15 -08:00
parent cb08b0c59b
commit a126ed6c3f
1 changed files with 33 additions and 7 deletions

View File

@ -16,8 +16,12 @@ jobs:
update_unity_beta_version: update_unity_beta_version:
name: Update Unity package to beta version name: Update Unity package to beta version
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Avoid running when the workflow's own automation merges the PR
# created by this workflow (prevents a version-bump loop).
if: github.actor != 'github-actions[bot]'
permissions: permissions:
contents: write contents: write
pull-requests: write
outputs: outputs:
unity_beta_version: ${{ steps.version.outputs.unity_beta_version }} unity_beta_version: ${{ steps.version.outputs.unity_beta_version }}
version_updated: ${{ steps.commit.outputs.updated }} version_updated: ${{ steps.commit.outputs.updated }}
@ -75,9 +79,12 @@ jobs:
echo "Updated MCPForUnity/package.json:" echo "Updated MCPForUnity/package.json:"
jq '.version' MCPForUnity/package.json jq '.version' MCPForUnity/package.json
- name: Commit and push beta version - name: Commit to temporary branch and create PR
id: commit id: commit
if: steps.version.outputs.already_beta != 'true' if: steps.version.outputs.already_beta != 'true'
env:
GH_TOKEN: ${{ github.token }}
BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }}
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
@ -87,17 +94,36 @@ jobs:
if git diff --quiet MCPForUnity/package.json; then if git diff --quiet MCPForUnity/package.json; then
echo "No changes to commit" echo "No changes to commit"
echo "updated=false" >> "$GITHUB_OUTPUT" echo "updated=false" >> "$GITHUB_OUTPUT"
else exit 0
git add MCPForUnity/package.json
git commit -m "chore: update Unity package to beta version ${{ steps.version.outputs.unity_beta_version }}"
git push origin beta
echo "updated=true" >> "$GITHUB_OUTPUT"
fi fi
# Create a temporary branch for the version update
BRANCH="beta-version-${BETA_VERSION}-${GITHUB_RUN_ID}"
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
git checkout -b "$BRANCH"
git add MCPForUnity/package.json
git commit -m "chore: update Unity package to beta version ${BETA_VERSION}"
git push origin "$BRANCH"
# Check if PR already exists
if gh pr view "$BRANCH" >/dev/null 2>&1; then
echo "PR already exists for $BRANCH"
else
PR_URL=$(gh pr create \
--base beta \
--head "$BRANCH" \
--title "chore: update Unity package to beta version ${BETA_VERSION}" \
--body "Automated beta version bump for the Unity package.")
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
fi
echo "updated=true" >> "$GITHUB_OUTPUT"
publish_pypi_prerelease: publish_pypi_prerelease:
name: Publish beta to PyPI (pre-release) name: Publish beta to PyPI (pre-release)
needs: update_unity_beta_version
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Avoid double-publish when the bot merges the version bump PR
if: github.actor != 'github-actions[bot]'
environment: environment:
name: pypi name: pypi
url: https://pypi.org/p/mcpforunityserver url: https://pypi.org/p/mcpforunityserver