Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add automatic github release #4466

Merged
merged 3 commits into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions build/current-changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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');
};
33 changes: 33 additions & 0 deletions build/gh-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var ghrelease = require('gh-release');
var currentChangelog = require('./current-changelog.js');
var safeParse = require('safe-json-parse/tuple');
var pkg = require('../package.json')

var options = {
owner: 'videojs',
repo: 'video.js',
body: currentChangelog(),
assets: ['./dist/videojs-'+pkg.version+'.zip'],
endpoint: 'https://api.github.com',
auth: {
username: process.env.VJS_GITHUB_USER,
password: process.env.VJS_GITHUB_TOKEN
}
};

var tuple = safeParse(process.env.npm_config_argv);
var npmargs = tuple[0] ? [] : tuple[1].cooked;

if (npmargs.some(function(arg) { return /next/.test(arg); })) {
options.prerelease = true;
}

ghrelease(options, function(err, result) {
if (err) {
console.log('Unable to publish release to github');
console.log(err);
} else {
console.log('Publish release to github!');
console.log(result);
}
});
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"docs:fix": "remark --output -- './**/*.md'",
"babel": "babel src/js -d es5",
"prepublish": "not-in-install && run-p docs:api build || in-install",
"publish": "node build/gh-release.js",
"prepush": "npm run lint -- --errors",
"version": "node build/version.js && git add CHANGELOG.md"
},
Expand Down Expand Up @@ -78,6 +79,7 @@
"es5-shim": "^4.1.3",
"es6-shim": "^0.35.1",
"filesize": "^3.5.6",
"gh-release": "^3.0.0",
"grunt": "^0.4.5",
"grunt-accessibility": "^5.0.0",
"grunt-babel": "^6.0.0",
Expand Down Expand Up @@ -129,6 +131,8 @@
"qunitjs": "1.23.1",
"remark-cli": "^3.0.0",
"remark-lint": "^6.0.0",
"remark-parse": "^3.0.1",
"remark-stringify": "^3.0.1",
"remark-toc": "^4.0.0",
"remark-validate-links": "^6.0.0",
"replace": "^0.3.0",
Expand All @@ -147,6 +151,7 @@
"time-grunt": "^1.1.1",
"tui-jsdoc-template": "^1.1.0",
"uglify-js": "~2.8.8",
"unified": "^6.1.5",
"videojs-doc-generator": "0.0.1",
"videojs-flash": "^2.0.0",
"videojs-standard": "^6.0.1",
Expand Down