-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ```
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters