Skip to content

Commit f9461b3

Browse files
authored
Merge pull request #36 from jsor-labs/changelog-feed
Implement changelog atom feeds
2 parents 5b78569 + 204ba00 commit f9461b3

File tree

6 files changed

+205
-2
lines changed

6 files changed

+205
-2
lines changed

bin/build

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,42 @@ if ($input->hasParameterOption('--dev-server')) {
8888
}
8989

9090
(new Symfony\Component\Filesystem\Filesystem())->remove($buildDir);
91+
(new Symfony\Component\Filesystem\Filesystem())->mkdir($buildDir);
92+
93+
(function (Symfony\Component\Console\Output\OutputInterface $output, string $buildDir, array $components): void {
94+
$output->write('Generating changelog.atom...');
95+
96+
$releases = array_slice(React\Website\Data\releases($components), 0, 10);
97+
98+
$feed = new Zend\Feed\Writer\Feed();
99+
100+
$feed->setId(getenv('DEPLOY_URL') . '/changelog.html');
101+
$feed->setLink(getenv('DEPLOY_URL') . '/changelog.html');
102+
$feed->setFeedLink(getenv('DEPLOY_URL') . '/changelog.atom', 'atom');
103+
104+
$feed->setLanguage('en');
105+
$feed->setTitle('The combined changelog for all ReactPHP components.');
106+
$feed->setDateModified((int) $releases[0]['date']->format('U'));
107+
108+
foreach ($releases as $release) {
109+
$entry = $feed->createEntry();
110+
111+
$entry->setTitle($release['component'] . ' ' . $release['version']);
112+
$entry->setLink($release['url']);
113+
$entry->setDateModified((int) $release['date']->format('U'));
114+
$entry->setDescription($release['html']);
115+
$entry->addAuthor($release['author']);
116+
117+
$feed->addEntry($entry);
118+
}
119+
120+
file_put_contents(
121+
$buildDir . '/changelog.atom',
122+
$feed->export('atom')
123+
);
124+
125+
$output->writeln('<info>Done</info>');
126+
})($output, $buildDir, $container['data.components']);
91127

92128
call_user_func(
93129
$container['generator'],

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"symfony/filesystem": "^3.2",
2424
"symfony/process": "^3.2",
2525
"vlucas/phpdotenv": "^2.4",
26-
"elvanto/litemoji": "^1.0"
26+
"elvanto/litemoji": "^1.0",
27+
"zendframework/zend-feed": "^2.10"
2728
}
2829
}

composer.lock

Lines changed: 153 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/data.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ function components(Client $client, CacheItemPoolInterface $markdownCache): arra
5151
'url' => $release['html_url'],
5252
'component' => $component['title'],
5353
'repository' => $component['repository'],
54+
'author' => [
55+
'name' => $release['author']['login'],
56+
'uri' => $release['author']['html_url'],
57+
'avatar' => $release['author']['avatar_url'],
58+
]
5459
];
5560
}
5661

theme/changelog.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{% extends 'default.html.twig' %}
22

3+
{% block head %}
4+
<link href="{{ base_url }}/changelog.atom" type="application/atom+xml" rel="alternate" title="Changelog">
5+
{% endblock %}
6+
37
{% block content %}
48

59
<div class="container">

theme/component-changelog.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{% extends 'component.html.twig' %}
22

33
{% block title %}{{ component.title ~ ': Changelog' }}{% endblock %}
4+
5+
{% block head %}
6+
<link href="https://github.com/{{ component.repository }}/releases.atom" type="application/atom+xml" rel="alternate" title="{{ component.title }} Changelog">
7+
{% endblock %}
8+
49
{% block component_content %}
510
<h1>{{ component.title }} Changelog</h1>
611

0 commit comments

Comments
 (0)