fix(ci): serialize version runs and bump on the fresh branch tip

Pushing main and development together raced: the main run's merge back
into development was rejected because the development run had moved it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 02:37:13 +01:00
1 parent 4140712c2e
commit 4516a1e4ef
1 file changed
+12 -2
+12 -2
View File
@@ -6,6 +6,11 @@ on:
permissions:
contents: write
# Pushes to main and development in quick succession must not bump or merge back concurrently.
concurrency:
group: version
cancel-in-progress: false
jobs:
bump:
if: >-
@@ -24,6 +29,9 @@ jobs:
git config user.name "version-bot"
git config user.email "version-bot@noreply.local"
branch="$GITHUB_REF_NAME"
# Bump on top of the branch tip, which an earlier run may have moved.
git fetch origin "$branch"
git checkout -B "$branch" "origin/$branch"
IFS=. read -r MA MI PA < VERSION
if [ "$branch" = development ]; then
PA=$((PA + 1))
@@ -32,7 +40,7 @@ jobs:
zero=0000000000000000000000000000000000000000
# MINOR bump only if every non-merge commit in this push is already on development.
if [ -n "$BEFORE" ] && [ "$BEFORE" != "$zero" ] &&
[ -z "$(git rev-list --no-merges "$BEFORE..HEAD" --not origin/development)" ]; then
[ -z "$(git rev-list --no-merges "$BEFORE..$GITHUB_SHA" --not origin/development)" ]; then
MI=$((MI + 1)); PA=0
else
PA=$((PA + 1))
@@ -44,7 +52,9 @@ jobs:
git push origin HEAD:"$branch"
if [ "$branch" = main ]; then
main_sha=$(git rev-parse HEAD)
git fetch origin development
git checkout -B development origin/development
git merge --no-ff -m "chore: merge main into development [skip ci]" "$main_sha"
# main's VERSION wins if development bumped in the meantime.
git merge --no-ff -X theirs -m "chore: merge main into development [skip ci]" "$main_sha"
git push origin development
fi