From 0bf4764a0720f6f199442a738a885a2edaae2a4d Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 20 Jul 2025 22:10:04 +0200 Subject: [PATCH] fix: resolve CI/CD version bump race condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added pull before push to handle concurrent workflow executions - Implemented retry logic with 3 attempts for push operations - Added fallback from rebase to merge if conflicts occur - Added proper error handling and logging for debugging This fixes the "non-fast-forward" error that occurs when multiple workflows run simultaneously and try to push version bumps. The workflow now: 1. Pulls latest changes before pushing 2. Retries up to 3 times with 5-second delays 3. Falls back to merge if rebase fails 4. Provides clear error messages for debugging 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .gitea/workflows/version-and-release.yml | 31 +++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/version-and-release.yml b/.gitea/workflows/version-and-release.yml index ebd5f8a..e6d2e3a 100644 --- a/.gitea/workflows/version-and-release.yml +++ b/.gitea/workflows/version-and-release.yml @@ -178,7 +178,36 @@ jobs: git commit -m "chore: bump frontend version to ${{ steps.version.outputs.new_version }}" fi - git push + # Pull latest changes before pushing to avoid conflicts + echo "Pulling latest changes from origin/main..." + if ! git pull --rebase origin main; then + echo "Rebase failed, attempting to resolve..." + # If rebase fails, abort and try a regular merge + git rebase --abort || true + git pull origin main --no-rebase + fi + + # Push the changes with retry logic + echo "Pushing version bump..." + MAX_RETRIES=3 + RETRY_COUNT=0 + + while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do + if git push origin main; then + echo "Successfully pushed version bump" + break + else + RETRY_COUNT=$((RETRY_COUNT + 1)) + if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then + echo "Push failed, retrying in 5 seconds... (attempt $RETRY_COUNT/$MAX_RETRIES)" + sleep 5 + git pull --rebase origin main || git pull origin main --no-rebase + else + echo "Failed to push after $MAX_RETRIES attempts" + exit 1 + fi + fi + done - name: Create Git tag if: steps.version.outputs.version_changed == 'true'