1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-10 11:10:19 +02:00
video.js/build/current-changelog.js
Gary Katsevman 3a600d0eea chore: add automatic github release (#4466)
This will automatically do a github release with the correct changelog entry and the built zip file.
If a publish is made with `--tag next` it will mark the release as a pre-release.

To use, just add `VJS_GITHUB_USER` and `VJS_GITHUB_TOKEN` env variables as part of the publish command:
```sh
$ VJS_GITHUB_USER=gkatsev VJS_GITHUB_TOKEN=test_token npm publish --tag next
```
2017-07-14 14:21:07 -04:00

34 lines
776 B
JavaScript

var unified = require('unified');
var markdown = require('remark-parse');
var stringify = require('remark-stringify');
var fs = require('fs');
module.exports = function() {
var processor = unified()
.use(markdown, {commonmark: true})
.use(stringify);
var ast = processor.parse(fs.readFileSync('./CHANGELOG.md'));
var changelog = [];
changelog.push(processor.stringify(ast.children[0]));
// start at 1 so we get the first anchor tag
// and can break on the second
for (var i = 1; i < ast.children.length; i++) {
var item = processor.stringify(ast.children[i]);
if (/^<a name="/.test(item)) {
break;
}
if (/^###/.test(item)) {
item = '\n' + item + '\n';
}
changelog.push(item);
}
return changelog.join('\n');
};