Upload index.json when publishing release
This commit is contained in:
parent
6b1f2215b2
commit
aa835ad38a
4 changed files with 35 additions and 10 deletions
|
@ -1,88 +0,0 @@
|
|||
var app = require('app');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var request = require('request');
|
||||
|
||||
var TARGET_URL = 'https://atom.io/download/atom-shell/index.json';
|
||||
|
||||
function getDate() {
|
||||
var today = new Date();
|
||||
var year = today.getFullYear();
|
||||
var month = today.getMonth() + 1;
|
||||
if (month <= 9)
|
||||
month = '0' + month;
|
||||
var day= today.getDate();
|
||||
if (day <= 9)
|
||||
day = '0' + day;
|
||||
return year + '-' + month + '-' + day;
|
||||
}
|
||||
|
||||
function getApmVersion() {
|
||||
var package = require(path.resolve(__dirname, '..', 'package.json'));
|
||||
return package.devDependencies['atom-package-manager'];
|
||||
}
|
||||
|
||||
function getInfoForCurrentVersion() {
|
||||
var json = {};
|
||||
json.version = process.versions['atom-shell'];
|
||||
json.date = getDate();
|
||||
json.apm = getApmVersion();
|
||||
|
||||
var names = ['node', 'v8', 'uv', 'zlib', 'openssl', 'modules', 'chrome']
|
||||
for (var i in names) {
|
||||
var name = names[i];
|
||||
json[name] = process.versions[name];
|
||||
}
|
||||
|
||||
json.files = [
|
||||
'darwin-x64',
|
||||
'darwin-x64-symbols',
|
||||
'linux-ia32',
|
||||
'linux-ia32-symbols',
|
||||
'linux-x64',
|
||||
'linux-x64-symbols',
|
||||
'win32-ia32',
|
||||
'win32-ia32-symbols',
|
||||
'win32-x64',
|
||||
'win32-x64-symbols',
|
||||
];
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
function getIndexJsInServer(callback) {
|
||||
request(TARGET_URL, function(e, res, body) {
|
||||
if (e)
|
||||
callback(e);
|
||||
else if (res.statusCode != 200)
|
||||
callback(new Error('Server returned ' + res.statusCode));
|
||||
else
|
||||
callback(null, JSON.parse(body));
|
||||
});
|
||||
}
|
||||
|
||||
function findObjectByVersion(all, version) {
|
||||
for (var i in all)
|
||||
if (all[i].version == version)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
app.on('ready', function() {
|
||||
getIndexJsInServer(function(e, all) {
|
||||
if (e) {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var current = getInfoForCurrentVersion();
|
||||
var found = findObjectByVersion(all, current.version);
|
||||
if (found == -1)
|
||||
all.unshift(current);
|
||||
else
|
||||
all[found] = current;
|
||||
|
||||
fs.writeFileSync(process.argv[2], JSON.stringify(all));
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
31
script/upload-index-json.py
Executable file
31
script/upload-index-json.py
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from lib.config import PLATFORM
|
||||
from lib.util import execute, s3_config, s3put, scoped_cwd
|
||||
|
||||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
|
||||
|
||||
|
||||
def main():
|
||||
# Upload the index.json.
|
||||
with scoped_cwd(SOURCE_ROOT):
|
||||
atom_shell = os.path.join(OUT_DIR, 'atom')
|
||||
if PLATFORM == 'win32':
|
||||
atom_shell += '.exe'
|
||||
index_json = os.path.relpath(os.path.join(OUT_DIR, 'index.json'))
|
||||
execute([atom_shell,
|
||||
os.path.join('tools', 'dump-version-info.js'),
|
||||
index_json])
|
||||
|
||||
bucket, access_key, secret_key = s3_config()
|
||||
s3put(bucket, access_key, secret_key, OUT_DIR, 'atom-shell/dist',
|
||||
[index_json])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
|
@ -119,16 +119,6 @@ def upload_node(bucket, access_key, secret_key, version):
|
|||
s3put(bucket, access_key, secret_key, DIST_DIR,
|
||||
'atom-shell/dist/{0}'.format(version), [node_lib])
|
||||
|
||||
# Upload the index.json.
|
||||
with scoped_cwd(SOURCE_ROOT):
|
||||
atom_shell = os.path.join(OUT_DIR, 'atom.exe')
|
||||
index_json = os.path.relpath(os.path.join(OUT_DIR, 'index.json'))
|
||||
execute([atom_shell,
|
||||
os.path.join('script', 'dump-version-info.js'),
|
||||
index_json])
|
||||
s3put(bucket, access_key, secret_key, OUT_DIR, 'atom-shell/dist',
|
||||
[index_json])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
|
|
@ -55,6 +55,10 @@ def main():
|
|||
os.path.join(SOURCE_ROOT, 'script', 'upload-checksums.py'),
|
||||
'-v', ATOM_SHELL_VERSION])
|
||||
|
||||
# Upload the index.json.
|
||||
execute([sys.executable,
|
||||
os.path.join(SOURCE_ROOT, 'script', 'upload-index-json.py')])
|
||||
|
||||
# Press the publish button.
|
||||
publish_release(github, release_id)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue