build: cleanup release scripts, separate cli entrypoints from logic (#44058)
* build: cleanup release scripts, separate cli entrypoints from logic * build: use repo/org constants
This commit is contained in:
parent
15c8759ee0
commit
f4ffd018e6
17 changed files with 410 additions and 300 deletions
|
@ -1,6 +1,7 @@
|
|||
import { Octokit } from '@octokit/rest';
|
||||
import * as fs from 'node:fs';
|
||||
import { createGitHubTokenStrategy } from '../github-token';
|
||||
import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from '../types';
|
||||
|
||||
if (process.argv.length < 6) {
|
||||
console.log('Usage: upload-to-github filePath fileName releaseId');
|
||||
|
@ -37,8 +38,8 @@ const getHeaders = (filePath: string, fileName: string) => {
|
|||
};
|
||||
};
|
||||
|
||||
function getRepo () {
|
||||
return releaseVersion.indexOf('nightly') > 0 ? 'nightlies' : 'electron';
|
||||
function getRepo (): ElectronReleaseRepo {
|
||||
return releaseVersion.indexOf('nightly') > 0 ? NIGHTLY_REPO : ELECTRON_REPO;
|
||||
}
|
||||
|
||||
const targetRepo = getRepo();
|
||||
|
@ -59,7 +60,7 @@ function uploadToGitHub () {
|
|||
headers: getHeaders(filePath, fileName),
|
||||
data: fileData as any,
|
||||
name: fileName,
|
||||
owner: 'electron',
|
||||
owner: ELECTRON_ORG,
|
||||
repo: targetRepo,
|
||||
release_id: releaseId
|
||||
}).then(() => {
|
||||
|
@ -71,7 +72,7 @@ function uploadToGitHub () {
|
|||
retry++;
|
||||
|
||||
octokit.repos.listReleaseAssets({
|
||||
owner: 'electron',
|
||||
owner: ELECTRON_ORG,
|
||||
repo: targetRepo,
|
||||
release_id: releaseId,
|
||||
per_page: 100
|
||||
|
@ -83,7 +84,7 @@ function uploadToGitHub () {
|
|||
if (existingAssets.length > 0) {
|
||||
console.log(`${fileName} already exists; will delete before retrying upload.`);
|
||||
octokit.repos.deleteReleaseAsset({
|
||||
owner: 'electron',
|
||||
owner: ELECTRON_ORG,
|
||||
repo: targetRepo,
|
||||
asset_id: existingAssets[0].id
|
||||
}).catch((deleteErr) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue