electron/script/release/find-github-release.js
trop[bot] ff65b58e2c
build: add support for fetching github token from sudowoodo (#43886)
* build: add support for fetching github token from sudowoodo

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>

* chore: update release notes cache for tests

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>

* build: support nightlies repo correctly

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>

* build: post token

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
2024-09-23 11:07:20 -07:00

46 lines
1 KiB
JavaScript

if (!process.env.CI) require('dotenv-safe').load();
const { Octokit } = require('@octokit/rest');
const { createGitHubTokenStrategy } = require('./github-token');
if (process.argv.length < 3) {
console.log('Usage: find-release version');
process.exit(1);
}
const version = process.argv[2];
const targetRepo = findRepo();
const octokit = new Octokit({
authStrategy: createGitHubTokenStrategy(targetRepo)
});
function findRepo () {
return version.indexOf('nightly') > 0 ? 'nightlies' : 'electron';
}
async function findRelease () {
const releases = await octokit.repos.listReleases({
owner: 'electron',
repo: targetRepo
});
const targetRelease = releases.data.find(release => release.tag_name === version);
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();