From 59d6c1e063c3fd0acd564b8130d4eb729d5c357b Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Thu, 16 Aug 2018 22:23:46 -0700 Subject: [PATCH] chore: use metadumper service to create index.json file (#14158) --- script/release.js | 10 ++-------- script/upload-index-json.py | 36 +++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/script/release.js b/script/release.js index 56f197321f8d..84e00ad4f309 100755 --- a/script/release.js +++ b/script/release.js @@ -180,11 +180,7 @@ function uploadNodeShasums () { function uploadIndexJson () { console.log('Uploading index.json to S3.') let scriptPath = path.join(__dirname, 'upload-index-json.py') - let scriptArgs = [] - if (args.automaticRelease) { - scriptArgs.push('-R') - } - runScript(scriptPath, scriptArgs) + runScript(scriptPath, [pkgVersion]) console.log(`${pass} Done uploading index.json to S3.`) } @@ -275,9 +271,7 @@ async function makeRelease (releaseToValidate) { checkVersion() let draftRelease = await getDraftRelease() uploadNodeShasums() - - // FIXME(codebytere): re-enable later - if (process.env.UPLOAD_INDEX_JSON) uploadIndexJson() + uploadIndexJson() await createReleaseShasums(draftRelease) // Fetch latest version of release before verifying diff --git a/script/upload-index-json.py b/script/upload-index-json.py index f5e5b3c7a6ad..88ebbb09ee47 100755 --- a/script/upload-index-json.py +++ b/script/upload-index-json.py @@ -2,32 +2,38 @@ import os import sys +import urllib2 -from lib.config import PLATFORM, s3_config -from lib.util import electron_gyp, execute, s3put, scoped_cwd - +from lib.config import s3_config +from lib.util import s3put, scoped_cwd, safe_mkdir SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'D') -PROJECT_NAME = electron_gyp()['project_name%'] -PRODUCT_NAME = electron_gyp()['product_name%'] +BASE_URL = 'https://electron-metadumper.herokuapp.com/?version=v' +version = sys.argv[1] +authToken = os.getenv('META_DUMPER_AUTH_HEADER') def main(): + if not authToken or authToken == "": + raise Exception("Please set META_DUMPER_AUTH_HEADER") # Upload the index.json. with scoped_cwd(SOURCE_ROOT): - if sys.platform == 'darwin': - electron = os.path.join(OUT_DIR, '{0}.app'.format(PRODUCT_NAME), - 'Contents', 'MacOS', PRODUCT_NAME) - elif sys.platform == 'win32': - electron = os.path.join(OUT_DIR, '{0}.exe'.format(PROJECT_NAME)) - else: - electron = os.path.join(OUT_DIR, PROJECT_NAME) + safe_mkdir(OUT_DIR) index_json = os.path.relpath(os.path.join(OUT_DIR, 'index.json')) - execute([electron, - os.path.join('tools', 'dump-version-info.js'), - index_json]) + + request = urllib2.Request( + BASE_URL + version, + headers={"Authorization" : authToken} + ) + + new_content = urllib2.urlopen( + request + ).read() + + with open(index_json, "w") as f: + f.write(new_content) bucket, access_key, secret_key = s3_config() s3put(bucket, access_key, secret_key, OUT_DIR, 'atom-shell/dist',