mirror of
https://github.com/videojs/video.js.git
synced 2024-11-28 08:58:46 +02:00
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 ```
This commit is contained in:
parent
1e80e59614
commit
3a600d0eea
33
build/current-changelog.js
Normal file
33
build/current-changelog.js
Normal file
@ -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
build/gh-release.js
Normal file
33
build/gh-release.js
Normal file
@ -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);
|
||||
}
|
||||
});
|
@ -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"
|
||||
},
|
||||
@ -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",
|
||||
@ -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",
|
||||
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user