Added docs for generating changelog + fixed some code (#8845)

This commit is contained in:
Neil Lathwood
2018-06-26 23:29:52 +01:00
committed by Tony Murray
parent e2c698bc68
commit c6fc763586
2 changed files with 30 additions and 15 deletions

View File

@@ -78,7 +78,7 @@ class GitHub
*/
public function getRelease($tag)
{
$release = Requests::get($this->github . "/releases/tags/$tag", self::getHeaders());
$release = Requests::get($this->github . "/releases/tags/$tag", $this->getHeaders());
return json_decode($release->body, true);
}
@@ -90,7 +90,7 @@ class GitHub
*/
public function getPullRequest()
{
$pull_request = Requests::get($this->github . "/pulls/{$this->pr}", self::getHeaders());
$pull_request = Requests::get($this->github . "/pulls/{$this->pr}", $this->getHeaders());
$this->pr = json_decode($pull_request->body, true);
}
@@ -104,7 +104,7 @@ class GitHub
*/
public function getPullRequests($date, $page = 1)
{
$prs = Requests::get($this->github . "/pulls?state=closed&page=$page", self::getHeaders());
$prs = Requests::get($this->github . "/pulls?state=closed&page=$page", $this->getHeaders());
$prs = json_decode($prs->body, true);
foreach ($prs as $k => $pr) {
if ($pr['merged_at']) {
@@ -139,7 +139,7 @@ class GitHub
$users[$pr['user']['login']] = 0;
}
if ($pr['merged_at']) {
foreach ($pr['labels'] as $k => $label) {
foreach ($pr['labels'] as $key => $label) {
$name = preg_replace('/ :[\S]+:/', '', strtolower($label['name']));
if (in_array($name, $this->labels)) {
$title = ucfirst(trim(preg_replace('/^[\S]+: /', '', $pr['title'])));
@@ -214,7 +214,7 @@ class GitHub
//FIXME Come back to this
return false;
$sha = isset($this->pr['merge_commit_sha']) ? $this->pr['merge_commit_sha'] : 'master';
$release = Requests::post($this->github . "/releases", self::getHeaders(), [
$release = Requests::post($this->github . "/releases", $this->getHeaders(), [
'tag_name' => $this->tag,
'target_commitish' => $sha,
'body' => $this->getMarkdown(),

View File

@@ -11,18 +11,33 @@ Enter a title, we usually use `August 2016 Release`
Enter a placeholder for the body, we will edit this later.
### Create changelog
We utilise [Readmegen](https://github.com/fojuth/readmegen) to automatically populate the Changelog.
For this, we assume you are using the master branch to create the release against.
Install `readmegen` using `composer`:
We now generate the changelog using the GitHub API itself so it shouldn't matter what state your local branch is in so
long as it has the code to generate the changelog itself.
Using the GitHub API means we can use the labels associated with merged pull requests to categorise the changelog. We
also then record who made the pull request to thank them in the changelog itself.
You will be asked for a GitHub personal access token. You can generate this [here](https://github.com/settings/tokens).
No permissions should be needed so just give it a name and click `Generate Token`. You can then export the token as an
environment variable `GH_TOKEN` or place it in your `.env` file.
The basic command to run is by using `artisan`. Here you pass `new tag` (1.41) and `previous tag` (1.40). For further
help run `php artisan release:tag --help`. This will generate a changelog up to the latest master branch, if you want
it to be done against something else then pass the latest pull request number with `--pr $PR_NUMBER`.
```bash
./scripts/composer_wrapper.php install
php artisan release:tag 1.41 1.40
```
You can now create the update change log by running (201608 was our last release):
```bash
./vendor/bin/readmegen --from 201608 --release 201609
```
Now commit and push the change that has been made to `doc\General\Changelog.md`
- Now commit and push the change that has been made to `doc/General/Changelog.md`.
- Once the pull request has been merged in for the Changelog, you can create a new release on
[GitHub](https://github.com/librenms/librenms/releases/new).
- Create two threads on the community site:
- A changelog thread [example](https://community.librenms.org/t/v1-40-release-changelog-may-2018/4228/1)
- An info thread [example](https://community.librenms.org/t/v1-40-may-2018-info/4229/)
- [Tweet it](https://twitter.com/librenms)
- [Facebook it](https://www.facebook.com/LibreNMS/)
- [Google Plus it](https://plus.google.com/u/1/b/110467424837711353117/)
- [LinkedIn it](https://www.linkedin.com/company/librenms/)