From 9bdf847f5627408204ac4b435ba937cacb4260d5 Mon Sep 17 00:00:00 2001 From: yusing Date: Thu, 18 Dec 2025 23:22:25 +0800 Subject: [PATCH] refactor(workflow): change merge strategy to cherry-pick for compatibility branch --- .github/workflows/merge-main-into-compat.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/merge-main-into-compat.yml b/.github/workflows/merge-main-into-compat.yml index 28946612..a9c4027f 100644 --- a/.github/workflows/merge-main-into-compat.yml +++ b/.github/workflows/merge-main-into-compat.yml @@ -1,12 +1,14 @@ -name: Merge Main Into Compat +name: Cherry-pick into Compat on: push: tags: - v* + paths: + - ".github/workflows/merge-main-into-compat.yml" jobs: - merge: + cherry-pick: runs-on: ubuntu-latest permissions: contents: write @@ -18,11 +20,20 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - - name: Merge main into compat + - name: Cherry-pick commits from last tag run: | git fetch origin compat git checkout compat - git merge --no-edit origin/main + CURRENT_TAG=${{ github.ref_name }} + PREV_TAG=$(git describe --tags --abbrev=0 $CURRENT_TAG^ 2>/dev/null || echo "") + + if [ -z "$PREV_TAG" ]; then + echo "No previous tag found. Cherry-picking all commits up to $CURRENT_TAG" + git rev-list --reverse --no-merges $CURRENT_TAG | xargs -r git cherry-pick + else + echo "Cherry-picking commits from $PREV_TAG to $CURRENT_TAG" + git rev-list --reverse --no-merges $PREV_TAG..$CURRENT_TAG | xargs -r git cherry-pick + fi - name: Push compat run: | git push origin compat