From ed26382e060aed16ba023cfdb4dd75e12732f0d9 Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Thu, 18 Jun 2026 13:16:47 +0200 Subject: [PATCH] ci: make release version bump idempotent updateComposerVersion() treated a no-op regex replace as fatal, so when composer.json already held the target version the release script aborted before tagging/publishing. This deadlocked the auto-release flow whenever the declared version drifted ahead of the latest git tag (e.g. a manual version bump merged inside a feature PR, as in #39). Count actual replacements instead: throw only when the version field is genuinely absent, and treat an already-correct value as success. This mirrors the existing behaviour of updateConstantVersion(). --- scripts/release/bump_version.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/release/bump_version.php b/scripts/release/bump_version.php index ff9fb42..70a1578 100644 --- a/scripts/release/bump_version.php +++ b/scripts/release/bump_version.php @@ -141,15 +141,21 @@ function updateComposerVersion(string $path, string $version): void throw new ReleaseScriptException('Could not read composer.json'); } + $count = 0; $updated = preg_replace( '/"version":\s*"[^"]*"/', '"version": "v' . $version . '"', $raw, - 1 + 1, + $count ); - if ($updated === null || $updated === $raw) { - throw new ReleaseScriptException('Could not update version in composer.json'); + if ($updated === null) { + throw new ReleaseScriptException('Regex failed while updating composer.json'); + } + + if ($count === 0) { + throw new ReleaseScriptException('Could not find version field in composer.json'); } file_put_contents($path, $updated);