From 65b4b655660476b1c1707f338af337d01ef478b0 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 22 May 2024 12:36:58 +0200 Subject: [PATCH] fix uploads --- .../ci/update_desktop_release_assets.ts | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/ci/update_desktop_release_assets.ts b/apps/remix-ide/ci/update_desktop_release_assets.ts index dd0a9b6130..51beba9dfb 100644 --- a/apps/remix-ide/ci/update_desktop_release_assets.ts +++ b/apps/remix-ide/ci/update_desktop_release_assets.ts @@ -5,11 +5,27 @@ import YAML from 'yaml' import crypto from 'crypto' const owner = 'remix-project-org' -const repo = 'remix-desktop' +let repo = 'remix-desktop' const headers = { 'X-GitHub-Api-Version': '2022-11-28', } +const version = getVersionFromPackageJson() +let channel = 'latest' + +if(version.includes('beta')) { + channel = 'beta' +} +if(version.includes('alpha')) { + channel = 'alpha' +} +if(version.includes('insiders')) { + channel = 'insiders' +} + +if(channel === 'latest') repo = 'remix-desktop' +repo = `remix-desktop-${channel}` + const octokit = new Octokit({ auth: process.env.GH_TOKEN_DESKTOP_PUBLISH, }) @@ -42,7 +58,7 @@ async function uploadReleaseAsset(release, name, file) { } } -async function getVersionFromPackageJson() { +function getVersionFromPackageJson() { // ignore ts error // eslint-disable-next-line @typescript-eslint/no-var-requires const packageJson = require(__dirname + '/../../../apps/remixdesktop/package.json') @@ -92,9 +108,10 @@ async function hashFile(file): Promise { } async function main() { + + + const allReleases = await getAllReleases() - const version = await getVersionFromPackageJson() - let channel = 'latest' console.log(`preparing release version: ${version}`) let release @@ -121,7 +138,7 @@ async function main() { let ymlFiles = await readReleaseFilesFromLocalDirectory() - ymlFiles = ymlFiles.filter((file) => file.endsWith('.yml') && file.startsWith(channel)) + ymlFiles = ymlFiles.filter((file) => file.endsWith('.yml') && file.startsWith('latest')) console.log(`Found ${ymlFiles.length} yml files to upload`) @@ -176,10 +193,10 @@ async function main() { let files = await readReleaseFilesFromLocalDirectory() try { - if (fs.existsSync(path.join(__dirname, '../../../release', `${channel}-mac-arm64.yml`)) && fs.existsSync(path.join(__dirname, '../../../release', `${channel}-mac-x64.yml`))) { + if (fs.existsSync(path.join(__dirname, '../../../release', `latest-mac-arm64.yml`)) && fs.existsSync(path.join(__dirname, '../../../release', `latest-mac-x64.yml`))) { // combine the two files - const macArm64 = fs.readFileSync(path.join(__dirname, '../../../release', `${channel}-mac-arm64.yml`), 'utf8') - const mac = fs.readFileSync(path.join(__dirname, '../../../release', `${channel}-mac-x64.yml`), 'utf8') + const macArm64 = fs.readFileSync(path.join(__dirname, '../../../release', `latest-mac-arm64.yml`), 'utf8') + const mac = fs.readFileSync(path.join(__dirname, '../../../release', `latest-mac-x64.yml`), 'utf8') const parsedMacArm64 = YAML.parse(macArm64) const parsedMac = YAML.parse(mac) console.log(parsedMacArm64) @@ -193,17 +210,17 @@ async function main() { } console.log(combined) const newYml = YAML.stringify(combined) - fs.writeFileSync(path.join(__dirname, '../../../release', `${channel}-mac.yml`), newYml) + fs.writeFileSync(path.join(__dirname, '../../../release', `latest-mac.yml`), newYml) // remove the arm64 file - fs.unlinkSync(path.join(__dirname, '../../../release', `${channel}-mac-arm64.yml`)) - fs.unlinkSync(path.join(__dirname, '../../../release', `${channel}-mac-x64.yml`)) + fs.unlinkSync(path.join(__dirname, '../../../release', `latest-mac-arm64.yml`)) + fs.unlinkSync(path.join(__dirname, '../../../release', `latest-mac-x64.yml`)) } } catch (e) { console.log(e) } files = await readReleaseFilesFromLocalDirectory() - files = files.filter((file) => file.endsWith('.zip') || file.endsWith('.dmg') || file.endsWith('.exe') || file.endsWith('.AppImage') || file.endsWith('.snap') || file.endsWith('.deb') || file.startsWith(`${channel}`)) + files = files.filter((file) => file.endsWith('.zip') || file.endsWith('.dmg') || file.endsWith('.exe') || file.endsWith('.AppImage') || file.endsWith('.snap') || file.endsWith('.deb') || file.startsWith(`latest`)) console.log(`Found ${files.length} files to upload`) console.log(files) if (!release.draft) {