Skip to content

Commit e5111b1

Browse files
feat: Add builds next option (#9946)
* feat: Add `builds next` option * fix: Add release changes for `builds` * fix: Apply suggestions * Apply suggestions from code review --------- Co-authored-by: John Paul E. Balandan, CPA <paulbalandan@gmail.com>
1 parent 120edf4 commit e5111b1

File tree

5 files changed

+48
-19
lines changed

5 files changed

+48
-19
lines changed

admin/RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ the existing content.
124124
* Set the date to format `Release Date: January 31, 2021`
125125
* Update **phpdoc.dist.xml** with the new `<title>CodeIgniter v4.x API</title>`
126126
and `<version number="4.x.x">`
127+
* Update **admin/starter/builds**:
128+
* Set `define('LATEST_RELEASE', '^4.x')`
129+
* Set `define('NEXT_MINOR', '4.y-dev')`.
130+
* If the major version changes, you need to manually change to `define('NEXT_MINOR', '5.0-dev')`.
127131
* Commit the changes with `Prep for 4.x.x release`
128132
* [ ] Create a new PR from `release-4.x.x` to `develop`:
129133
* Title: `Prep for 4.x.x release`

admin/prepare-release.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ function replace_file_content(string $path, string $pattern, string $replace): v
2424
$versionParts = explode('.', $version);
2525
$minor = $versionParts[0] . '.' . $versionParts[1];
2626

27+
// Note: Major version will change someday (4.x..5.x) - update manually.
28+
$nextMinor = $versionParts[0] . '.' . $versionParts[1] + 1;
29+
2730
// Creates a branch for release.
2831
system('git switch develop');
2932
system('git branch -D release-' . $version);
@@ -68,6 +71,18 @@ function replace_file_content(string $path, string $pattern, string $replace): v
6871
"Release Date: {$date}",
6972
);
7073

74+
// Update appstarter/builds script
75+
replace_file_content(
76+
'./admin/starter/builds',
77+
'/define\(\'LATEST_RELEASE\', \'.*?\'\);/mu',
78+
"define('LATEST_RELEASE', '^{$minor}');",
79+
);
80+
replace_file_content(
81+
'./admin/starter/builds',
82+
'/define\(\'NEXT_MINOR\', \'.*?\'\);/mu',
83+
"define('NEXT_MINOR', '^{$nextMinor}-dev');",
84+
);
85+
7186
// Commits
7287
system('git add -u');
7388
system('git commit -m "Prep for ' . $version . ' release"');

admin/starter/builds

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env php
22
<?php
33

4-
define('LATEST_RELEASE', '^4.0');
4+
define('LATEST_RELEASE', '^4.7');
5+
define('DEVELOP_BRANCH', 'dev-develop');
6+
define('NEXT_MINOR', '^4.8-dev');
57
define('GITHUB_URL', 'https://github.com/codeigniter4/codeigniter4');
68

79
/*
@@ -11,18 +13,18 @@ define('GITHUB_URL', 'https://github.com/codeigniter4/codeigniter4');
1113
* Use this script to toggle the CodeIgniter dependency between the
1214
* latest stable release and the most recent development update.
1315
*
14-
* Usage: php builds [release|development]
16+
* Usage: php builds [release|development|next]
1517
*/
1618

19+
$branch = $argv[1] ?? '';
20+
1721
// Determine the requested stability
18-
if (empty($argv[1]) || ! in_array($argv[1], ['release', 'development'], true)) {
19-
echo 'Usage: php builds [release|development]' . PHP_EOL;
22+
if ($branch === '' || ! in_array($branch, ['release', 'development', 'next'], true)) {
23+
echo 'Usage: php builds [release|development|next]' . PHP_EOL;
2024

2125
exit;
2226
}
2327

24-
$dev = $argv[1] === 'development';
25-
2628
$modified = [];
2729

2830
// Locate each file and update it for the requested stability
@@ -36,7 +38,7 @@ if (is_file($file)) {
3638
$array = json_decode($contents, true);
3739

3840
if (is_array($array)) {
39-
if ($dev) {
41+
if ($branch !== 'release') {
4042
$array['minimum-stability'] = 'dev';
4143
$array['prefer-stable'] = true;
4244
$array['repositories'] ??= [];
@@ -57,7 +59,7 @@ if (is_file($file)) {
5759
];
5860
}
5961

60-
$array['require']['codeigniter4/codeigniter4'] = 'dev-develop';
62+
$array['require']['codeigniter4/codeigniter4'] = $branch === 'next' ? NEXT_MINOR : DEVELOP_BRANCH;
6163
unset($array['require']['codeigniter4/framework']);
6264
} else {
6365
unset($array['minimum-stability']);
@@ -70,7 +72,7 @@ if (is_file($file)) {
7072
}
7173
}
7274

73-
if (empty($array['repositories'])) {
75+
if ($array['repositories'] === []) {
7476
unset($array['repositories']);
7577
}
7678
}
@@ -100,7 +102,7 @@ foreach ($files as $file) {
100102
if (is_file($file)) {
101103
$contents = file_get_contents($file);
102104

103-
if ($dev) {
105+
if ($branch !== 'release') {
104106
$contents = str_replace('vendor/codeigniter4/framework', 'vendor/codeigniter4/codeigniter4', $contents);
105107
} else {
106108
$contents = str_replace('vendor/codeigniter4/codeigniter4', 'vendor/codeigniter4/framework', $contents);
@@ -120,6 +122,7 @@ if ($modified === []) {
120122
foreach ($modified as $file) {
121123
echo " * {$file}" . PHP_EOL;
122124
}
123-
124-
echo 'Run `composer update` to sync changes with your vendor folder.' . PHP_EOL;
125125
}
126+
127+
echo 'Run `composer update` to sync changes with your vendor folder.' . PHP_EOL;
128+
echo 'Don\'t forget to update the project files in app folder from "vendor/codeigniter4/*/app/".' . PHP_EOL;

user_guide_src/source/changelogs/v4.7.1.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Message Changes
2424
Changes
2525
*******
2626

27+
Others
28+
======
29+
30+
- **builds:** In the ``builds`` script (for ``codeigniter4/appstarter``), the ``next`` argument has been added
31+
to switch ``4.7.x`` to the next minor version ``4.8.x-dev``. See :ref:`Latest Dev<switch-to-dev-version>`.
32+
2733
************
2834
Deprecations
2935
************

user_guide_src/source/installation/installing_composer.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ Folders in your project after set up:
158158
- app, public, tests, writable
159159
- vendor/codeigniter4/framework/system
160160

161+
.. _switch-to-dev-version:
162+
161163
Latest Dev
162164
----------
163165

@@ -169,6 +171,9 @@ The `development user guide <https://codeigniter4.github.io/CodeIgniter4/>`_ is
169171
Note that this differs from the released user guide, and will pertain to the
170172
develop branch explicitly.
171173

174+
.. note:: You should not rely on the version of the framework in your project
175+
- the development code may contain an incorrect number.
176+
172177
Update for Latest Dev
173178
^^^^^^^^^^^^^^^^^^^^^
174179

@@ -188,15 +193,11 @@ files if necessary.
188193
Next Minor Version
189194
^^^^^^^^^^^^^^^^^^
190195

191-
If you want to use the next minor version branch, after using the ``builds`` command
192-
edit **composer.json** manually.
196+
If you want to use the next minor version branch:
193197

194-
If you try the ``4.8`` branch, change the version to ``4.8.x-dev``::
198+
.. code-block:: console
195199
196-
"require": {
197-
"php": "^8.2",
198-
"codeigniter4/codeigniter4": "4.8.x-dev"
199-
},
200+
php builds next
200201
201202
And run ``composer update`` to sync your vendor
202203
folder with the latest target build. Then, check the Upgrading Guide

0 commit comments

Comments
 (0)