2018-07-19 18:48:13 +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');
|
2024-09-23 18:07:20 +00:00
|
|
|
const { createGitHubTokenStrategy } = require('./github-token');
|
2018-07-09 22:46:31 +00:00
|
|
|
|
|
|
|
if (process.argv.length < 3) {
|
|
|
|
console.log('Usage: find-release version');
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const version = process.argv[2];
|
2024-05-31 17:58:39 +00:00
|
|
|
const targetRepo = findRepo();
|
|
|
|
|
2024-09-23 18:07:20 +00:00
|
|
|
const octokit = new Octokit({
|
|
|
|
authStrategy: createGitHubTokenStrategy(targetRepo)
|
|
|
|
});
|
|
|
|
|
2024-05-31 17:58:39 +00:00
|
|
|
function findRepo () {
|
2024-06-25 21:25:04 +00:00
|
|
|
return version.indexOf('nightly') > 0 ? 'nightlies' : 'electron';
|
2024-05-31 17:58:39 +00:00
|
|
|
}
|
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',
|
2024-05-31 17:58:39 +00:00
|
|
|
repo: targetRepo
|
2018-07-09 22:46:31 +00:00
|
|
|
});
|
2019-01-08 20:05:58 +00:00
|
|
|
|
|
|
|
const targetRelease = releases.data.find(release => release.tag_name === version);
|
2018-07-09 22:46:31 +00:00
|
|
|
let returnObject = {};
|
|
|
|
|
|
|
|
if (targetRelease) {
|
|
|
|
returnObject = {
|
|
|
|
id: targetRelease.id,
|
|
|
|
draft: targetRelease.draft,
|
|
|
|
exists: true
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
returnObject = {
|
|
|
|
exists: false,
|
|
|
|
draft: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
console.log(JSON.stringify(returnObject));
|
|
|
|
}
|
|
|
|
|
|
|
|
findRelease();
|