From 950830d40a08d5cf0f53b9640f6ae0eb1594d676 Mon Sep 17 00:00:00 2001 From: Dmitrii Safronov Date: Sat, 6 Dec 2025 17:40:15 +0400 Subject: [PATCH] chore(workflow): add sync step to update main branch after release - Introduced a new step in the GitHub Actions workflow to synchronize the main branch with the release branch after a successful release. This includes checks for fast-forwarding or rebasing to ensure the main branch is up to date with the latest changes from release. Signed-off-by: Dmitrii Safronov --- .github/workflows/release-stable.yaml | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/release-stable.yaml b/.github/workflows/release-stable.yaml index faea449..a217572 100644 --- a/.github/workflows/release-stable.yaml +++ b/.github/workflows/release-stable.yaml @@ -33,3 +33,36 @@ jobs: -e GITHUB_TOKEN=${{ secrets.SEMANTIC_RELEASE_TOKEN || secrets.GITHUB_TOKEN }} \ -e CI=true \ ghcr.io/disafronov/semantic-release:latest + + - name: Sync release to main + if: success() + run: | + git config user.name "Release Bot" + git config user.email "noreply@github.com" + + # Fetch latest state after semantic-release pushed commits + # This ensures we get all commits that semantic-release created + git fetch origin release:release + git fetch origin main:main + + # Check if main is already up to date + if git diff --quiet main release; then + echo "main is already up to date with release" + exit 0 + fi + + # Check if main is ancestor of release (can fast-forward) + if git merge-base --is-ancestor main release; then + echo "Fast-forwarding main to release" + git checkout main + git merge --ff-only release + git push origin main + else + echo "Rebasing main onto release (force-with-lease required)" + git checkout main + git rebase release + # Use --force-with-lease for safety: only push if remote hasn't changed + git push --force-with-lease origin main + fi + env: + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN || secrets.GITHUB_TOKEN }}