Skip to content

Commit 09a6494

Browse files
committed
Merge pull request php-curl-class#122 from zachborboa/master
Add bump major, minor, and patch version scripts for semantic versioning
2 parents 4fab0f3 + c2be7a7 commit 09a6494

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

scripts/bump_major_version.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/php
2+
<?php
3+
require dirname(__FILE__) . '/../src/Curl/Curl.php';
4+
5+
$current_version = Curl\Curl::VERSION;
6+
list($major, $minor, $patch) = explode('.', $current_version);
7+
$new_version = implode('.', array((string)((int)$major += 1), $minor, $patch));
8+
9+
foreach(
10+
array(
11+
array(
12+
dirname(__FILE__) . '/../composer.json',
13+
'/"version": "(?:\d+.\d+.\d+)"/',
14+
'"version": "' . $new_version . '"',
15+
),
16+
array(
17+
dirname(__FILE__) . '/../src/Curl/Curl.php',
18+
'/const VERSION = \'(?:\d+.\d+.\d+)\';/',
19+
'const VERSION = \'' . $new_version . '\';',
20+
),
21+
) as $info) {
22+
list($filepath, $find, $replace) = $info;
23+
$data = preg_replace($find, $replace, file_get_contents($filepath));
24+
file_put_contents($filepath, $data);
25+
}

scripts/bump_minor_version.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/php
2+
<?php
3+
require dirname(__FILE__) . '/../src/Curl/Curl.php';
4+
5+
$current_version = Curl\Curl::VERSION;
6+
list($major, $minor, $patch) = explode('.', $current_version);
7+
$new_version = implode('.', array($major, (string)((int)$minor += 1), $patch));
8+
9+
foreach(
10+
array(
11+
array(
12+
dirname(__FILE__) . '/../composer.json',
13+
'/"version": "(?:\d+.\d+.\d+)"/',
14+
'"version": "' . $new_version . '"',
15+
),
16+
array(
17+
dirname(__FILE__) . '/../src/Curl/Curl.php',
18+
'/const VERSION = \'(?:\d+.\d+.\d+)\';/',
19+
'const VERSION = \'' . $new_version . '\';',
20+
),
21+
) as $info) {
22+
list($filepath, $find, $replace) = $info;
23+
$data = preg_replace($find, $replace, file_get_contents($filepath));
24+
file_put_contents($filepath, $data);
25+
}

scripts/bump_patch_version.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/php
2+
<?php
3+
require dirname(__FILE__) . '/../src/Curl/Curl.php';
4+
5+
$current_version = Curl\Curl::VERSION;
6+
list($major, $minor, $patch) = explode('.', $current_version);
7+
$new_version = implode('.', array($major, $minor, (string)((int)$patch += 1)));
8+
9+
foreach(
10+
array(
11+
array(
12+
dirname(__FILE__) . '/../composer.json',
13+
'/"version": "(?:\d+.\d+.\d+)"/',
14+
'"version": "' . $new_version . '"',
15+
),
16+
array(
17+
dirname(__FILE__) . '/../src/Curl/Curl.php',
18+
'/const VERSION = \'(?:\d+.\d+.\d+)\';/',
19+
'const VERSION = \'' . $new_version . '\';',
20+
),
21+
) as $info) {
22+
list($filepath, $find, $replace) = $info;
23+
$data = preg_replace($find, $replace, file_get_contents($filepath));
24+
file_put_contents($filepath, $data);
25+
}

0 commit comments

Comments
 (0)