mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Undo (#16690)
* Revert "fix asset fail workaround (#16680)" This reverts commite61c8543f1. * Revert "build: hack around GitHub upload API failure / flake (#16667)" This reverts commit1098d0f414.
This commit is contained in:
@@ -15,47 +15,35 @@ const releaseVersion = process.argv[5]
|
||||
|
||||
const targetRepo = releaseVersion.indexOf('nightly') > 0 ? 'nightlies' : 'electron'
|
||||
|
||||
const githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: targetRepo,
|
||||
id: releaseId,
|
||||
filePath: filePath,
|
||||
name: fileName
|
||||
}
|
||||
|
||||
let retry = 0
|
||||
|
||||
function uploadToGitHub () {
|
||||
const fakeFileNamePrefix = `fake-${fileName}-fake-`
|
||||
const fakeFileName = `${fakeFileNamePrefix}${Date.now()}`
|
||||
const githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: targetRepo,
|
||||
id: releaseId,
|
||||
filePath: filePath,
|
||||
name: fakeFileName
|
||||
}
|
||||
|
||||
github.repos.uploadAsset(githubOpts).then((uploadResponse) => {
|
||||
console.log(`Successfully uploaded ${fileName} to GitHub as ${fakeFileName}. Going for the rename now.`)
|
||||
return github.repos.editAsset({
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
id: uploadResponse.data.id,
|
||||
name: fileName
|
||||
}).then(() => {
|
||||
console.log(`Successfully renamed ${fakeFileName} to ${fileName}. All done now.`)
|
||||
process.exit(0)
|
||||
})
|
||||
github.repos.uploadAsset(githubOpts).then(() => {
|
||||
console.log(`Successfully uploaded ${fileName} to GitHub.`)
|
||||
process.exit()
|
||||
}).catch((err) => {
|
||||
if (retry < 4) {
|
||||
console.log(`Error uploading ${fileName} as ${fakeFileName} to GitHub, will retry. Error was:`, err)
|
||||
console.log(`Error uploading ${fileName} to GitHub, will retry. Error was:`, err)
|
||||
retry++
|
||||
github.repos.getRelease(githubOpts).then(release => {
|
||||
console.log('Got list of assets for existing release:')
|
||||
console.log(JSON.stringify(release.data.assets, null, ' '))
|
||||
const existingAssets = release.data.assets.filter(asset => asset.name.startsWith(fakeFileNamePrefix) || asset.name === fileName)
|
||||
const existingAssets = release.data.assets.filter(asset => asset.name === fileName)
|
||||
if (existingAssets.length > 0) {
|
||||
console.log(`${fileName} already exists; will delete before retrying upload.`)
|
||||
Promise.all(
|
||||
existingAssets.map(existingAsset => github.repos.deleteAsset({
|
||||
owner: 'electron',
|
||||
repo: targetRepo,
|
||||
id: existingAsset.id
|
||||
}))
|
||||
).catch((deleteErr) => {
|
||||
github.repos.deleteAsset({
|
||||
owner: 'electron',
|
||||
repo: targetRepo,
|
||||
id: existingAssets[0].id
|
||||
}).catch((deleteErr) => {
|
||||
console.log(`Failed to delete existing asset ${fileName}. Error was:`, deleteErr)
|
||||
}).then(uploadToGitHub)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user