3cb6042b10
- Added the first version of release-utils - Will release a v0.0.1 - Be able to create changelog.md based on previous version. - Be able to merge & clean changelog.md. - Be able to create a gist - Be able to filter commits by emojis (user-facing changes) - Be able to create a draft release - Be able to upload a release zip to Github The goal is to use our release-utils in multiple places (e.g. in Casper). We will discuss if we want to replace some of our manual written utilities by existing npm packages. But to avoid breaking everything, we do it iteratively. Our release utils works and was designed based on our needs. We've tested some release utility in the past, they were all not really satisfying. TBC...
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
const fs = require('fs');
|
|
const requestPromise = require('request-promise');
|
|
|
|
const localUtils = require('./utils');
|
|
|
|
module.exports.create = (options = {}) => {
|
|
let isPublic = true;
|
|
|
|
localUtils.checkMissingOptions(options,
|
|
'changelogPath',
|
|
'gistName',
|
|
'gistDescription',
|
|
'github',
|
|
'github.username',
|
|
'github.token',
|
|
'userAgent'
|
|
);
|
|
|
|
if (options.hasOwnProperty('isPublic')) {
|
|
isPublic = options.isPublic;
|
|
}
|
|
|
|
const content = fs.readFileSync(options.changelogPath);
|
|
const files = {};
|
|
|
|
files[options.gistName] = {
|
|
content: content.toString('utf8')
|
|
};
|
|
|
|
const auth = 'Basic ' + new Buffer(options.github.username + ':' + options.github.token).toString('base64');
|
|
|
|
const reqOptions = {
|
|
uri: 'https://api.github.com/gists',
|
|
headers: {
|
|
'User-Agent': options.userAgent,
|
|
Authorization: auth
|
|
},
|
|
method: 'POST',
|
|
body: {
|
|
description: options.gistDescription,
|
|
public: isPublic,
|
|
files: files
|
|
},
|
|
json: true,
|
|
resolveWithFullResponse: true
|
|
};
|
|
|
|
return requestPromise(reqOptions)
|
|
.then((response) => {
|
|
return {
|
|
gistUrl: response.body.html_url
|
|
};
|
|
});
|
|
};
|