Skip to content

Commit 0a1eda4

Browse files
committed
Release v0.8.0-alpha
1 parent fe23e3c commit 0a1eda4

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

bump-version.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,35 @@ private function validateVersion($version)
4747
private function updateBuildScript($newVersion)
4848
{
4949
$content = file_get_contents($this->buildScript);
50-
$pattern = "/private \$version = '[^']+';/";
51-
$replacement = "private \$version = '$newVersion';";
52-
53-
$newContent = preg_replace($pattern, $replacement, $content);
54-
55-
if ($newContent === $content) {
50+
$patterns = [
51+
// Class property
52+
"/(private\s+\\\$version\s*=\s*')[^']+(');/",
53+
// Global variable
54+
"/(\\\$version\s*=\s*')[^']+(');/"
55+
];
56+
$replacement = "\$version = '$newVersion';";
57+
58+
$newContent = preg_replace($patterns, $replacement, $content);
59+
60+
$updated = false;
61+
foreach ($patterns as $pattern) {
62+
$newContent = preg_replace(
63+
$pattern,
64+
"\$1{$newVersion}\$2;",
65+
$content,
66+
-1,
67+
$count
68+
);
69+
if ($count) {
70+
file_put_contents($this->buildScript, $newContent);
71+
$updated = true;
72+
break;
73+
}
74+
}
75+
76+
if (! $updated) {
5677
throw new Exception("Could not find version in build script");
5778
}
58-
59-
file_put_contents($this->buildScript, $newContent);
6079
}
6180

6281
private function updateManifest($newVersion)
@@ -80,8 +99,9 @@ private function updateManifest($newVersion)
8099
public function getCurrentVersion()
81100
{
82101
$content = file_get_contents($this->buildScript);
83-
if (preg_match("/private \\\$version = '([^']+)';/", $content, $matches)) {
84-
return $matches[1];
102+
if (preg_match("/private\s+\\\$version\s*=\s*'([^']+)';/", $content, $m)
103+
|| preg_match("/\\\$version\s*=\s*'([^']+)';/", $content, $m)) {
104+
return $m[1];
85105
}
86106
return null;
87107
}

component_manifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<authorUrl>https://github.com/username/gsoc25_api</authorUrl>
77
<copyright>Copyright (C) 2025 Reem. All rights reserved.</copyright>
88
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
9-
<version>__DEPLOY_VERSION__</version>
9+
<version>0.8.0-alpha</version>
1010
<description>COM_CCM_DESCRIPTION</description>
1111

1212
<install>

0 commit comments

Comments
 (0)