Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDevelop committed Jan 16, 2019
2 parents 20fd8a6 + 4801ac8 commit 1a610e2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![version](https://img.shields.io/badge/Version-0.1.0-brightgreen.svg)](https://github.com/SimonDevelop/releaser-bot/releases/tag/0.1.0)
[![version](https://img.shields.io/badge/Version-0.2.0-brightgreen.svg)](https://github.com/SimonDevelop/releaser-bot/releases/tag/0.2.0)
[![Minimum Node Version](https://img.shields.io/badge/node-%3E%3D%206-brightgreen.svg)](https://nodejs.org/en/)
[![GitHub license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/SimonDevelop/releaser-bot/blob/master/LICENSE)
# releaser-bot
Expand All @@ -9,6 +9,8 @@ The bot will just listen to the webhooks of your projects github, is a push is d

With your type message commit in config.json, use `patch`, `minor` and `major` to specify the release.

The description of the releases is based on the commit message after a line break `\n\n`.

## Install
```bash
$ npm install
Expand All @@ -27,4 +29,4 @@ Specify the content type on application/json and check `Just the push event.`.

## TODO
- [x] Simple release creation
- [ ] Add description release
- [x] Add description release with commit body
19 changes: 18 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function checkRepos(name) {
if (!error && response.statusCode == 200) {
data.json = body;
data.emit('commit');
} else {
console.log("Reposiroty does not exist or unauthorized access");
}
});
}
Expand All @@ -65,8 +67,23 @@ data.on('commit', function () {
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
var regMessage = new RegExp(config.commitMessage, "gi");
// check and compare commit sha
if (body[0].commit.message.match(regMessage) != null
&& (typeof data.commit == "undefined" || data.commit != body[0].sha.substr(0, 6))) {
// Generate release description
var split = body[0].commit.message.split("\n\n");
var array = [];
if (split.length > 1) {
for (var i=0; i < split.length; i++) {
if (i > 0) {
array.push(split[i]);
}
}
data.description = array.join("\n\n");
} else {
data.description = "";
}
// Storage commit sha
data.commit = body[0].sha.substr(0, 6);
data.emit('release');
} else {
Expand Down Expand Up @@ -122,7 +139,7 @@ data.on('create', function () {
"tag_name": newRelease.tag,
"target_commitish": "master",
"name": newRelease.name,
"body": "",
"body": data.description,
"draft": false,
"prerelease": false
};
Expand Down

0 comments on commit 1a610e2

Please sign in to comment.