Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions scripts/release/bump_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading