From c97131b7f11368c0dbf6d262be08e5314eeeab5e Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Wed, 10 Sep 2025 13:39:18 -0700 Subject: [PATCH 1/5] queue cherry pick workflows to prevent simultaneous actions --- .github/workflows/cherryPick.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 88cf51bed974..f7c7aa17026f 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -29,6 +29,10 @@ on: type: string required: true +concurrency: + group: "cherrypick" + cancel-in-progress: false + jobs: createNewVersion: uses: ./.github/workflows/createNewVersion.yml From 72e858ba78bd24fa740322cde1f9bdc702a9ec01 Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Wed, 10 Sep 2025 13:45:55 -0700 Subject: [PATCH 2/5] Fix cherry-pick race condition using commit-then-cherry-pick approach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When PRs are merged during workflow execution, git checkout main fails with "local changes would be overwritten by checkout". This fix: 1. Commits version changes in detached HEAD state 2. Safely checkout main (no uncommitted changes) 3. Cherry-pick the version commit onto main This preserves the exact commit App expects while avoiding checkout conflicts. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/createNewVersion.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/createNewVersion.yml b/.github/workflows/createNewVersion.yml index 84e22d394fef..451503c2249b 100644 --- a/.github/workflows/createNewVersion.yml +++ b/.github/workflows/createNewVersion.yml @@ -84,9 +84,7 @@ jobs: - name: Commit new Mobile-Expensify version working-directory: Mobile-Expensify run: | - # Checkout main branch in Mobile-Expensify submodule. - # This is IMPORTANT so that when we make changes, we aren't in a detached head state, and when we later push those changes to main, it works! - git checkout main + # First commit the version changes in detached HEAD state git add \ ./Android/AndroidManifest.xml \ ./app/config/config.json \ @@ -94,6 +92,12 @@ jobs: ./iOS/SmartScanExtension/Info.plist \ ./iOS/NotificationServiceExtension/Info.plist git commit -m "Update version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}" + + # Now checkout main branch (safe because no uncommitted changes) + git checkout main + + # Cherry-pick the version bump commit onto main + git cherry-pick HEAD@{1} if ! git push origin main; then echo "Race condition! Mobile-Expensify main was updated while this workflow was running, so push failed. Fetching remote, rebasing, and retrying push once." git fetch origin main From 553c99d137cba1064a4f31e0e577472def835fcd Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Wed, 10 Sep 2025 14:43:04 -0700 Subject: [PATCH 3/5] Fix cherry-pick race condition using commit-then-cherry-pick approach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When PRs are merged during workflow execution, git checkout main fails with "local changes would be overwritten by checkout". This fix: 1. Commits version changes in detached HEAD state 2. Captures the exact commit hash before checkout 3. Safely checkout main (no uncommitted changes) 4. Cherry-pick the specific version commit onto main This preserves the exact commit App expects while avoiding checkout conflicts. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/createNewVersion.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/createNewVersion.yml b/.github/workflows/createNewVersion.yml index 451503c2249b..2783bdb606f3 100644 --- a/.github/workflows/createNewVersion.yml +++ b/.github/workflows/createNewVersion.yml @@ -84,7 +84,7 @@ jobs: - name: Commit new Mobile-Expensify version working-directory: Mobile-Expensify run: | - # First commit the version changes in detached HEAD state + # First commit the version changes on detached HEAD git add \ ./Android/AndroidManifest.xml \ ./app/config/config.json \ @@ -92,12 +92,13 @@ jobs: ./iOS/SmartScanExtension/Info.plist \ ./iOS/NotificationServiceExtension/Info.plist git commit -m "Update version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}" + + # Store the commit hash before checkout to ensure we cherry-pick the right commit + DETACHED_COMMIT=$(git rev-parse HEAD) - # Now checkout main branch (safe because no uncommitted changes) + # Cherry-pick the version bump commit onto main, to safely handle case where new commits exist on main git checkout main - - # Cherry-pick the version bump commit onto main - git cherry-pick HEAD@{1} + git cherry-pick $DETACHED_COMMIT if ! git push origin main; then echo "Race condition! Mobile-Expensify main was updated while this workflow was running, so push failed. Fetching remote, rebasing, and retrying push once." git fetch origin main From 709b91cbcbdfcd16a82dede4e8ade7137da5d595 Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Wed, 10 Sep 2025 14:58:49 -0700 Subject: [PATCH 4/5] fix GH action formatting --- .github/workflows/createNewVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/createNewVersion.yml b/.github/workflows/createNewVersion.yml index 2783bdb606f3..8d51c2f67226 100644 --- a/.github/workflows/createNewVersion.yml +++ b/.github/workflows/createNewVersion.yml @@ -98,7 +98,7 @@ jobs: # Cherry-pick the version bump commit onto main, to safely handle case where new commits exist on main git checkout main - git cherry-pick $DETACHED_COMMIT + git cherry-pick "$DETACHED_COMMIT" if ! git push origin main; then echo "Race condition! Mobile-Expensify main was updated while this workflow was running, so push failed. Fetching remote, rebasing, and retrying push once." git fetch origin main From 41d5ffe2c264a4e0d0aac588c8fde33b472765a7 Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Wed, 10 Sep 2025 15:18:58 -0700 Subject: [PATCH 5/5] make sure we update main before cherrypicking the version bump --- .github/workflows/createNewVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/createNewVersion.yml b/.github/workflows/createNewVersion.yml index 8d51c2f67226..cb8970454080 100644 --- a/.github/workflows/createNewVersion.yml +++ b/.github/workflows/createNewVersion.yml @@ -97,7 +97,7 @@ jobs: DETACHED_COMMIT=$(git rev-parse HEAD) # Cherry-pick the version bump commit onto main, to safely handle case where new commits exist on main - git checkout main + git checkout main && git pull origin main git cherry-pick "$DETACHED_COMMIT" if ! git push origin main; then echo "Race condition! Mobile-Expensify main was updated while this workflow was running, so push failed. Fetching remote, rebasing, and retrying push once."