Commit 5cd5e229 authored by Robert Knight's avatar Robert Knight

Use Octokit to create GitHub release

Since we're using GitHub's Node REST client already, use it to create
the GitHub release instead of making a "manual" HTTP request.
parent dba8aac6
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
* `v<VERSION>` where <VERSION> is the `version` field in package.json. * `v<VERSION>` where <VERSION> is the `version` field in package.json.
*/ */
const request = require('request');
const octokit = require('@octokit/rest')(); const octokit = require('@octokit/rest')();
const pkg = require('../package.json'); const pkg = require('../package.json');
...@@ -34,28 +33,16 @@ async function createGitHubRelease() { ...@@ -34,28 +33,16 @@ async function createGitHubRelease() {
const changes = await changelistSinceTag(octokit); const changes = await changelistSinceTag(octokit);
const release = { const [owner, repo] = pkg.repository.split('/');
tag_name: `v${pkg.version}`,
name: `v${pkg.version}`, await octokit.repos.createRelease({
body: changes, body: changes,
draft: false, draft: false,
name: `v${pkg.version}`,
owner,
prerelease: true, prerelease: true,
}; repo,
tag_name: `v${pkg.version}`,
request.post({
uri: `https://api.github.com/repos/${pkg.repository}/releases`,
body: release,
json: true,
headers: {
Authorization: `token ${process.env.GITHUB_TOKEN}`,
'User-Agent': `${pkg.repository} Release Script`,
},
}, (err, rsp, body) => {
if (err || rsp.statusCode !== 201) {
const msg = err ? err.message : `${rsp.statusCode}: ${JSON.stringify(body)}`;
throw new Error(`Creating GitHub release failed: ${msg}`);
}
console.info(`Created GitHub release for v${pkg.version}`);
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment