xref: /web-php/bin/bumpRelease (revision 97f5bbe6)
1#!/usr/bin/env php
2<?php
3(PHP_SAPI === 'cli') or die("Please run this script using the cli sapi");
4
5require_once __DIR__ . "/../include/branches.inc";
6require_once __DIR__ . "/../include/version.inc";
7require_once __DIR__ . "/../include/releases.inc";
8
9if ($_SERVER['argc'] < 1) {
10	fwrite(STDERR, "Usage: {$_SERVER['argv'][0]} major_version [ minor_version ]\n");
11	exit(1);
12}
13
14$major = (int) $_SERVER['argv'][1];
15isset($RELEASES[$major]) or die("Unknown major version $major");
16$minor = isset($_SERVER['argv'][2]) ? (int) $_SERVER['argv'][2] : null;
17
18$version = get_current_release_for_branch($major, $minor);
19$info = $RELEASES[$major][$version] ?? null;
20
21if ($info === null) {
22	fwrite(STDERR, "Unable to find a current PHP release for {$major}.{$minor}\n");
23	exit(1);
24}
25
26$info["museum"] = false;
27if ($info["announcement"] === true) {
28	$info["announcement"] = array("English" => "/releases/" . str_replace(".", "_", $version) . ".php");
29}
30
31$OLDRELEASES[$major] = array_merge(
32	array($version => $info),
33	$OLDRELEASES[$major] ?? []
34);
35
36file_put_contents(__DIR__ . "/../include/releases.inc", [
37	"<?php\n\$OLDRELEASES = ",
38	var_export($OLDRELEASES, true),
39	";\n",
40]);
41
42echo "This was fun \o/\nI hope you remembered to run this script *before* updating include/version.inc... :)\n";
43