|
73 | 73 |
|
74 | 74 | echo sprintf("Prepare symfony version \"%s\".\n", $rawVersion);
|
75 | 75 |
|
| 76 | +/** |
| 77 | + * prepare sfCoreAutoload class |
| 78 | + */ |
| 79 | +$file = __DIR__.'/../lib/autoload/sfCoreAutoload.class.php'; |
| 80 | +$content = file_get_contents($file); |
| 81 | + |
| 82 | +$content = preg_replace('/^define\(.*SYMFONY_VERSION.*$/m', 'define(\'SYMFONY_VERSION\', \''.$rawVersion.'\');', $content, -1, $count); |
| 83 | + |
| 84 | +if ($count !== 1) { |
| 85 | + throw new \RuntimeException('Preparing sfCoreAutoload failed, SYMFONY_VERSION constant not found.'); |
| 86 | +} |
| 87 | + |
| 88 | +file_put_contents($file, $content); |
| 89 | + |
| 90 | +/** |
| 91 | + * prepare CHANGELOG.md |
| 92 | + */ |
| 93 | +$file = __DIR__.'/../CHANGELOG.md'; |
| 94 | +$content = file_get_contents($file); |
| 95 | + |
| 96 | +$nextVersionHeader = <<<EOL |
| 97 | +xx/xx/xxxx: Version 1.5.xx |
| 98 | +-------------------------- |
| 99 | +
|
| 100 | +
|
| 101 | +
|
| 102 | +
|
| 103 | +EOL; |
| 104 | + |
| 105 | +$changelogHeader = sprintf('%s: Version %s', date('d/m/Y'), $rawVersion); |
| 106 | +$content = preg_replace('/^xx\/xx\/xxxx.*$/m', $nextVersionHeader.$changelogHeader, $content, -1, $count); |
| 107 | + |
| 108 | +if ($count !== 1) { |
| 109 | + throw new \RuntimeException('Preparing CHANGELOG.md failed. Template line not found.'); |
| 110 | +} |
| 111 | + |
| 112 | +file_put_contents($file, $content); |
| 113 | + |
| 114 | +/** |
| 115 | + * content prepare end |
| 116 | + */ |
| 117 | + |
| 118 | +echo "Please check the changes before commit and tagging.\n"; |
| 119 | + |
| 120 | +passthru('git diff'); |
| 121 | + |
| 122 | +echo "Is everything ok? (y/N)\n"; |
| 123 | + |
| 124 | +$answer = readline(); |
| 125 | + |
| 126 | +if (strtolower($answer) !== 'y') { |
| 127 | + echo "Revert changes.\n"; |
| 128 | + exec('git checkout lib/autoload/sfCoreAutoload.class.php'); |
| 129 | + exec('git checkout CHANGELOG.md'); |
| 130 | + echo "Stopped.\n"; |
| 131 | + exit(1); |
| 132 | +} |
| 133 | + |
| 134 | +chdir(__DIR__.'/..'); |
| 135 | +exec('git add lib/autoload/sfCoreAutoload.class.php'); |
| 136 | +exec('git add CHANGELOG.md'); |
| 137 | +exec('git commit -m "Prepare release '.$rawVersion.'"'); |
| 138 | +exec('git tag -a '.$version.' -m "Release '.$rawVersion.'"'); |
| 139 | +exec('git push origin '.$version); |
| 140 | + |
| 141 | + |
76 | 142 | exit(0);
|
0 commit comments