From a126ed6c3fac02d89ec1d41ae1af15c41750c002 Mon Sep 17 00:00:00 2001 From: dsarno Date: Mon, 2 Feb 2026 18:49:15 -0800 Subject: [PATCH] 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 --- .github/workflows/beta-release.yml | 40 ++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index b149296..eb2cdcf 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -16,8 +16,12 @@ jobs: update_unity_beta_version: name: Update Unity package to beta version 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: contents: write + pull-requests: write outputs: unity_beta_version: ${{ steps.version.outputs.unity_beta_version }} version_updated: ${{ steps.commit.outputs.updated }} @@ -75,9 +79,12 @@ jobs: echo "Updated MCPForUnity/package.json:" jq '.version' MCPForUnity/package.json - - name: Commit and push beta version + - name: Commit to temporary branch and create PR id: commit if: steps.version.outputs.already_beta != 'true' + env: + GH_TOKEN: ${{ github.token }} + BETA_VERSION: ${{ steps.version.outputs.unity_beta_version }} shell: bash run: | set -euo pipefail @@ -87,17 +94,36 @@ jobs: if git diff --quiet MCPForUnity/package.json; then echo "No changes to commit" echo "updated=false" >> "$GITHUB_OUTPUT" - else - 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" + exit 0 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: name: Publish beta to PyPI (pre-release) - needs: update_unity_beta_version runs-on: ubuntu-latest + # Avoid double-publish when the bot merges the version bump PR + if: github.actor != 'github-actions[bot]' environment: name: pypi url: https://pypi.org/p/mcpforunityserver