Skip to content

Commit e806d7a

Browse files
Add prepare release script
Fixes issue #286
1 parent a4f836f commit e806d7a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

build/release-prepare

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
$version = $argv[1] ?? '';
5+
$installer = $argv[2] ?? '';
6+
7+
if (empty($version) || !preg_match('/^\d+\.\d+\.\d+$/', $version)) {
8+
printHelp();
9+
echo "\nversion number is missing\n";
10+
exit(1);
11+
}
12+
13+
$root = realpath(__DIR__ . '/..') . '/';
14+
$file = $root . 'src/CH.php';
15+
$ch = file_get_contents($file);
16+
$date = date('Y-m-d');
17+
18+
// update version number
19+
$ch = preg_replace("~VERSION = '[0-9]+\.[0-9]+.[0-9]';~", "VERSION = '$version';", $ch);
20+
// update release date
21+
$ch = preg_replace("~RELEASE_DATE = '[0-9]+-[0-9]+-[0-9]+';~", "RELEASE_DATE = '$date';", $ch);
22+
// update the installer version
23+
if (!empty($installer)) {
24+
$ch = preg_replace("~MIN_REQ_INSTALLER = '[0-9]+\.[0-9]+.[0-9]';~", "MIN_REQ_INSTALLER = '$installer';", $ch);
25+
}
26+
27+
file_put_contents($file, $ch);
28+
29+
`git add $file`;
30+
`git commit -m'Prepare version $version'`;
31+
`git tag -asm'Version $version' $version`;
32+
33+
function printHelp(): void {
34+
echo 'release-prepare' . PHP_EOL
35+
. 'Usage:' . PHP_EOL
36+
. ' command [<version> <installer>]' . PHP_EOL . PHP_EOL
37+
. 'Arguments:' . PHP_EOL
38+
. ' version New version number (semver)' . PHP_EOL
39+
. ' installer New required installer version' . PHP_EOL;
40+
}

0 commit comments

Comments
 (0)