Skip to content

Instantly share code, notes, and snippets.

@co3k
Created September 3, 2010 17:50
Show Gist options
  • Save co3k/564252 to your computer and use it in GitHub Desktop.
Save co3k/564252 to your computer and use it in GitHub Desktop.
<?php
require_once 'SymfonyComponents/YAML/sfYaml.php';
function output_ticket_title($title)
{
preg_match('/^.+?#(?P<ticket_id>[0-9]+):(?P<ticket_subject>.*)$/', $title, $matches);
$author = '';
$authors = array();
$ticket_info = simplexml_load_file('http://redmine.openpne.jp/issues/'.$matches['ticket_id'].'.xml');
$changesets = $ticket_info->changesets;
if ($changesets)
{
foreach ($changesets->changeset as $changeset)
{
$attr = $changeset->user->attributes();
$authors[] = (string)$attr->name;
}
}
$_authors = array_count_values($authors);
arsort($_authors);
if ($_authors)
{
reset($_authors);
$author = key($_authors);
}
echo '#'.$matches['ticket_id'].':'.$matches['ticket_subject'];
if ($author)
{
echo ' ('.$author.')';
}
}
function get_updated_plugin_info($before, $after)
{
$result = array();
$before_list = sfYaml::load(file_get_contents('https://trac.openpne.jp/svn/OpenPNE3/bandled-plugins-list/'.$before.'.yml'));
$after_list = sfYaml::load(file_get_contents('https://trac.openpne.jp/svn/OpenPNE3/bandled-plugins-list/'.$after.'.yml'));
foreach ($after_list as $after_plugin => $after_version)
{
if (!isset($before_list[$after_plugin]))
{
$result[$after_plugin] = '(追加)';
continue;
}
if ($before_list[$after_plugin]['version'] !== $after_list[$after_plugin]['version'])
{
$result[$after_plugin] = $before_list[$after_plugin]['version'].'-&gt;'.$after_list[$after_plugin]['version'];
}
}
return $result;
}
if (1 === $argc)
{
echo '
Usage:
php openpne-release-blog.php version before_version redmine_version_id
'.PHP_EOL;
exit;
}
$version = $argv[1];
$before_version = $argv[2];
$redmine_version_id = $argv[3];
$updated_plugins = get_updated_plugin_info($before_version, $version);
$version_parts = explode('.', $version);
$is_stable = !((bool)strpos($version, 'beta') || ($version_parts[1] % 2));
$date_formatter = new IntlDateFormatter('ja_JP', IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'Asia/Tokyo', IntlDateFormatter::GREGORIAN, 'yyyy/MM/dd (EEE)');
$redmine_version_url = 'http://redmine.openpne.jp/versions/show/'.$redmine_version_id;
$document = new DOMDocument();
$document->loadHTMLFile($redmine_version_url);
$ticket_list = $document->getElementsByTagName('fieldset')->item(1)->getElementsByTagName('li');
$enhancements = array();
$bugs = array();
$others = array();
foreach ($ticket_list as $t)
{
if (false !== strpos($t->nodeValue, 'Enhancement'))
{
$enhancements[] = $t->nodeValue;
}
elseif (false !== strpos($t->nodeValue, 'Bug') || false !== strpos($t->nodeValue, 'Backport'))
{
$bugs[] = $t->nodeValue;
}
else
{
$others[] = $t->nodeValue;
}
}
shuffle($bugs);
$bugs = array_chunk($bugs, 5);
if ($bugs)
{
$bugs = $bugs[0];
}
shuffle($enhancements);
$enhancements = array_chunk($enhancements, 5);
if ($enhancements)
{
$enhancements = $enhancements[0];
}
?>
OpenPNE 開発チームの海老原です。
本日 <?php echo $date_formatter->format(time()) ?>、<?php echo $is_stable ? '安定版': '開発版'; ?> OpenPNE <?php echo $version ?> をリリースしました。
<!--more-->
<?php if ($enhancements): ?>
<h2>機能追加・機能改善</h2>
<ul>
<?php foreach ($enhancements as $ticket): ?>
<li><?php echo output_ticket_title($ticket); ?></li>
<?php endforeach; ?>
</ul>
その他の機能追加・機能改善については、<a href="<?php echo $redmine_version_url ?>">redmine.openpne.jp のバージョン情報</a> をご覧ください。
<?php endif; ?>
<?php if ($bugs): ?>
<h2>バグ修正</h2>
※こちらに掲載されているバグ修正は、「安定版で既に修正されたもの」「これからリリースされる安定版でも修正されるもの」が含まれます。
<ul>
<?php foreach ($bugs as $ticket): ?>
<li><?php echo output_ticket_title($ticket); ?></li>
<?php endforeach; ?>
</ul>
その他のバグ修正については、<a href="<?php echo $redmine_version_url ?>">redmine.openpne.jp のバージョン情報</a> をご覧ください。
<?php endif; ?>
<?php if ($updated_plugins): ?>
<h2>バンドルされるプラグインの追加・更新情報</h2>
<dl>
<?php foreach ($updated_plugins as $plugin => $plugin_version): ?>
<dt><?php echo $plugin ?> <?php echo $plugin_version ?></dt>
<dd><a href="http://www.openpne.jp/archives/5184/">リリース告知</a></dd>
<?php endforeach; ?>
</dl>
<?php endif; ?>
<h2>バージョンアップ・インストール</h2>
<h3>バージョンアップ</h3>
バージョンアップ方法は、<a href="http://github.com/openpne/OpenPNE3/raw/OpenPNE-<?php echo $version ?>/doc/ja/OpenPNE3_Version_Up_Guide.txt">バージョンアップ手順</a> をご覧ください。
<h3>インストール</h3>
インストール方法は、同梱の <a href="http://github.com/openpne/OpenPNE3/raw/OpenPNE-<?php echo $version ?>/doc/ja/OpenPNE3_Setup_Guide.txt">セットアップ手順</a> をご覧ください。
<h2>ダウンロード・バージョン情報</h2>
<h3>ダウンロード</h3>
<a href="http://www.openpne.jp/pne-downloads">http://www.openpne.jp/pne-downloads</a>
<h3>バージョン情報</h3>
<a href="<?php echo $redmine_version_url ?>">redmine.openpne.jp のバージョン情報</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment