2020-03-20 20:28:31 +00:00
|
|
|
if (!process.env.CI) require('dotenv-safe').load();
|
2018-07-11 18:02:03 +00:00
|
|
|
|
2020-08-05 15:59:52 +00:00
|
|
|
const { Octokit } = require('@octokit/rest');
|
|
|
|
const octokit = new Octokit({
|
2019-05-08 01:48:40 +00:00
|
|
|
auth: process.env.ELECTRON_GITHUB_TOKEN
|
2020-03-20 20:28:31 +00:00
|
|
|
});
|
2018-07-09 22:46: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);
|
2018-07-09 22:46:31 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = process.argv[2];
|
2018-07-09 22:46:31 +00:00
|
|
|
|
|
|
|
async function findRelease () {
|
2019-01-08 20:05:58 +00:00
|
|
|
const releases = await octokit.repos.listReleases({
|
2018-07-09 22:46:31 +00:00
|
|
|
owner: 'electron',
|
2018-08-16 15:57:12 +00:00
|
|
|
repo: version.indexOf('nightly') > 0 ? 'nightlies' : 'electron'
|
2020-03-20 20:28:31 +00:00
|
|
|
});
|
2019-01-08 20:05:58 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const targetRelease = releases.data.find(release => release.tag_name === version);
|
|
|
|
let returnObject = {};
|
2018-07-09 22:46:31 +00:00
|
|
|
|
|
|
|
if (targetRelease) {
|
|
|
|
returnObject = {
|
|
|
|
id: targetRelease.id,
|
|
|
|
draft: targetRelease.draft,
|
|
|
|
exists: true
|
2020-03-20 20:28:31 +00:00
|
|
|
};
|
2018-07-09 22:46:31 +00:00
|
|
|
} else {
|
|
|
|
returnObject = {
|
|
|
|
exists: false,
|
|
|
|
draft: false
|
2020-03-20 20:28:31 +00:00
|
|
|
};
|
2018-07-09 22:46:31 +00:00
|
|
|
}
|
2020-03-20 20:28:31 +00:00
|
|
|
console.log(JSON.stringify(returnObject));
|
2018-07-09 22:46:31 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
findRelease();
|