electron/script/release/find-github-release.js

40 lines
882 B
JavaScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
if (!process.env.CI) require('dotenv-safe').load();
2018-07-11 18:02:03 +00:00
const { Octokit } = require('@octokit/rest');
const octokit = new Octokit({
auth: process.env.ELECTRON_GITHUB_TOKEN
2020-03-20 20:28:31 +00:00
});
if (process.argv.length < 3) {
2020-03-20 20:28:31 +00:00
console.log('Usage: find-release version');
process.exit(1);
}
2020-03-20 20:28:31 +00:00
const version = process.argv[2];
async function findRelease () {
const releases = await octokit.repos.listReleases({
owner: 'electron',
repo: version.indexOf('nightly') > 0 ? 'nightlies' : 'electron'
2020-03-20 20:28:31 +00:00
});
2020-03-20 20:28:31 +00:00
const targetRelease = releases.data.find(release => release.tag_name === version);
let returnObject = {};
if (targetRelease) {
returnObject = {
id: targetRelease.id,
draft: targetRelease.draft,
exists: true
2020-03-20 20:28:31 +00:00
};
} else {
returnObject = {
exists: false,
draft: false
2020-03-20 20:28:31 +00:00
};
}
2020-03-20 20:28:31 +00:00
console.log(JSON.stringify(returnObject));
}
2020-03-20 20:28:31 +00:00
findRelease();