Skip to content

Commit 7fd1fd4

Browse files
committed
chore: plugin bump version script added
1 parent 6293b51 commit 7fd1fd4

File tree

2 files changed

+88
-29
lines changed

2 files changed

+88
-29
lines changed

bump-version.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
if ($argc < 2) {
4+
echo "Usage: composer bump-version [new-version]\n";
5+
exit(1);
6+
}
7+
8+
$newVersion = $argv[1];
9+
$pluginFile = 'bitwpfi.php';
10+
$configFile = 'includes/Config.php';
11+
$readmeFile = 'readme.txt';
12+
13+
if (!file_exists($pluginFile) || !file_exists($readmeFile) || !file_exists($configFile)) {
14+
echo "Required files not found.\n";
15+
exit(1);
16+
}
17+
18+
$pluginContent = file_get_contents($pluginFile);
19+
$configContent = file_get_contents($configFile);
20+
$readmeContent = file_get_contents($readmeFile);
21+
22+
$pluginContent = preg_replace_callback(
23+
'/^(\s*\*\s*Version:\s*)([\d\.]+)/m',
24+
function ($matches) use ($newVersion) {
25+
return $matches[1] . $newVersion;
26+
},
27+
$pluginContent
28+
);
29+
30+
$pluginContent = preg_replace_callback(
31+
"/(define\s*\(\s*'BTCBI_VERSION'\s*,\s*')[\d\.]+('\s*\);)/",
32+
function ($matches) use ($newVersion) {
33+
return $matches[1] . $newVersion . $matches[2];
34+
},
35+
$pluginContent
36+
);
37+
38+
$configContent = preg_replace_callback(
39+
"/(public\s+const\s+VERSION\s*=\s*')([\d\.]+)(';)/",
40+
function ($matches) use ($newVersion) {
41+
return $matches[1] . $newVersion . $matches[3];
42+
},
43+
$configContent
44+
);
45+
46+
$readmeContent = preg_replace_callback(
47+
'/^(Stable tag:\s*)([\d\.]+)/m',
48+
function ($matches) use ($newVersion) {
49+
return $matches[1] . $newVersion;
50+
},
51+
$readmeContent
52+
);
53+
54+
file_put_contents($pluginFile, $pluginContent);
55+
file_put_contents($configFile, $configContent);
56+
file_put_contents($readmeFile, $readmeContent);
57+
58+
echo "Updated Version v{$newVersion}\n";

composer.json

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
{
2-
"name": "bitapps/bit-integrations",
3-
"description": "An Integration plugin for wordpress",
4-
"license": "GPL-2.0-or-later",
5-
"autoload": {
6-
"psr-4": {
7-
"BitCode\\FI\\": "includes/"
8-
}
9-
},
10-
"require-dev": {
11-
"phpcompatibility/phpcompatibility-wp": "*",
12-
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
13-
"friendsofphp/php-cs-fixer": "^3.54"
14-
},
15-
"scripts": {
16-
"version-checker": "phpcs -p --standard=PHPCompatibilityWP --runtime-set testVersion 5.6- includes"
17-
},
18-
"config": {
19-
"allow-plugins": {
20-
"dealerdirect/phpcodesniffer-composer-installer": true,
21-
"typisttech/imposter-plugin": true
22-
}
23-
},
24-
"require": {
25-
"bitapps/wp-telemetry": "v0.0.9",
26-
"typisttech/imposter-plugin": "*"
27-
},
2+
"name": "bitapps/bit-integrations",
3+
"description": "An Integration plugin for wordpress",
4+
"license": "GPL-2.0-or-later",
5+
"autoload": {
6+
"psr-4": {
7+
"BitCode\\FI\\": "includes/"
8+
}
9+
},
10+
"require-dev": {
11+
"phpcompatibility/phpcompatibility-wp": "*",
12+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
13+
"friendsofphp/php-cs-fixer": "^3.54"
14+
},
15+
"scripts": {
16+
"version-checker": "phpcs -p --standard=PHPCompatibilityWP --runtime-set testVersion 7.4- includes",
17+
"bump-version": "php bump-version.php"
18+
},
19+
"config": {
20+
"allow-plugins": {
21+
"dealerdirect/phpcodesniffer-composer-installer": true,
22+
"typisttech/imposter-plugin": true
23+
}
24+
},
25+
"require": {
26+
"bitapps/wp-telemetry": "v0.0.9",
27+
"typisttech/imposter-plugin": "*"
28+
},
2829
"extra": {
29-
"imposter": {
30-
"namespace": "BTCBI\\Deps\\"
31-
}
30+
"imposter": {
31+
"namespace": "BTCBI\\Deps\\"
3232
}
33+
}
3334
}

0 commit comments

Comments
 (0)