fix: improve version bump workflow with better conflict resolution
- Added pre-fetch and check before committing to ensure we're up-to-date - Improved retry logic with clearer output and better error handling - Added explicit fetch before each retry attempt - Use for-loop instead of while for clearer retry counting - Better fallback from rebase to merge on conflicts - Added set -e to fail fast on errors - More verbose logging for debugging This should resolve the persistent "non-fast-forward" errors by: 1. Checking if we're behind before even committing 2. Pulling changes if needed 3. Retrying with proper synchronization 4. Providing clear debug output 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -164,11 +164,25 @@ jobs:
|
|||||||
- name: Commit version bump
|
- name: Commit version bump
|
||||||
if: steps.version.outputs.version_changed == 'true'
|
if: steps.version.outputs.version_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
|
set -e # Exit on any error
|
||||||
|
|
||||||
|
# First, ensure we have the latest changes
|
||||||
|
echo "Fetching latest changes..."
|
||||||
|
git fetch origin main
|
||||||
|
|
||||||
|
# Check if we're behind and need to update
|
||||||
|
LOCAL=$(git rev-parse HEAD)
|
||||||
|
REMOTE=$(git rev-parse origin/main)
|
||||||
|
|
||||||
|
if [ "$LOCAL" != "$REMOTE" ]; then
|
||||||
|
echo "Local is behind remote, pulling changes..."
|
||||||
|
git pull origin main --no-rebase
|
||||||
|
fi
|
||||||
|
|
||||||
COMPONENT="${{ steps.version.outputs.component_changed }}"
|
COMPONENT="${{ steps.version.outputs.component_changed }}"
|
||||||
|
|
||||||
if [ "$COMPONENT" = "both" ]; then
|
if [ "$COMPONENT" = "both" ]; then
|
||||||
git add backend/package.json backend/package-lock.json
|
git add backend/package.json backend/package-lock.json frontend/package.json frontend/package-lock.json
|
||||||
git add frontend/package.json frontend/package-lock.json
|
|
||||||
git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }} (backend + frontend)"
|
git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }} (backend + frontend)"
|
||||||
elif [ "$COMPONENT" = "backend" ]; then
|
elif [ "$COMPONENT" = "backend" ]; then
|
||||||
git add backend/package.json backend/package-lock.json
|
git add backend/package.json backend/package-lock.json
|
||||||
@@ -189,25 +203,40 @@ jobs:
|
|||||||
|
|
||||||
# Push the changes with retry logic
|
# Push the changes with retry logic
|
||||||
echo "Pushing version bump..."
|
echo "Pushing version bump..."
|
||||||
MAX_RETRIES=3
|
PUSH_SUCCESS=false
|
||||||
RETRY_COUNT=0
|
|
||||||
|
|
||||||
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
for i in 1 2 3; do
|
||||||
if git push origin main; then
|
echo "Push attempt $i of 3..."
|
||||||
echo "Successfully pushed version bump"
|
|
||||||
|
# Try to push
|
||||||
|
if git push origin main 2>&1; then
|
||||||
|
echo "Successfully pushed version bump on attempt $i"
|
||||||
|
PUSH_SUCCESS=true
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
echo "Push failed on attempt $i"
|
||||||
if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
|
|
||||||
echo "Push failed, retrying in 5 seconds... (attempt $RETRY_COUNT/$MAX_RETRIES)"
|
if [ $i -lt 3 ]; then
|
||||||
|
echo "Waiting 5 seconds before retry..."
|
||||||
sleep 5
|
sleep 5
|
||||||
git pull --rebase origin main || git pull origin main --no-rebase
|
|
||||||
else
|
echo "Pulling latest changes..."
|
||||||
echo "Failed to push after $MAX_RETRIES attempts"
|
git fetch origin main
|
||||||
exit 1
|
|
||||||
|
# Try rebase first, fall back to merge
|
||||||
|
if ! git rebase origin/main; then
|
||||||
|
echo "Rebase failed, trying merge..."
|
||||||
|
git rebase --abort 2>/dev/null || true
|
||||||
|
git pull origin main --no-rebase
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "$PUSH_SUCCESS" = "false" ]; then
|
||||||
|
echo "ERROR: Failed to push after 3 attempts"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Create Git tag
|
- name: Create Git tag
|
||||||
if: steps.version.outputs.version_changed == 'true'
|
if: steps.version.outputs.version_changed == 'true'
|
||||||
|
|||||||
Reference in New Issue
Block a user