Make sure dist is created for the HEAD before uploading.
This commit is contained in:
parent
02ba7d27b9
commit
0af724205c
2 changed files with 31 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
|
import contextlib
|
||||||
import errno
|
import errno
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -18,6 +19,16 @@ def tempdir(prefix=''):
|
||||||
return directory
|
return directory
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def scoped_cwd(path):
|
||||||
|
cwd = os.getcwd()
|
||||||
|
os.chdir(path)
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
os.chdir(cwd)
|
||||||
|
|
||||||
|
|
||||||
def download(text, url, path):
|
def download(text, url, path):
|
||||||
with open(path, 'w') as local_file:
|
with open(path, 'w') as local_file:
|
||||||
web_file = urllib2.urlopen(url)
|
web_file = urllib2.urlopen(url)
|
||||||
|
|
|
@ -4,8 +4,11 @@ import errno
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from lib.util import *
|
||||||
|
|
||||||
|
|
||||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
|
||||||
|
@ -13,6 +16,9 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
ensure_s3put()
|
ensure_s3put()
|
||||||
|
if not dist_newer_than_head():
|
||||||
|
create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
|
||||||
|
subprocess.check_call([sys.executable, create_dist])
|
||||||
upload()
|
upload()
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
return e.message
|
return e.message
|
||||||
|
@ -28,6 +34,20 @@ def ensure_s3put():
|
||||||
assert 'multipart' in output, 'Error: Please install boto and filechunkio'
|
assert 'multipart' in output, 'Error: Please install boto and filechunkio'
|
||||||
|
|
||||||
|
|
||||||
|
def dist_newer_than_head():
|
||||||
|
with scoped_cwd(SOURCE_ROOT):
|
||||||
|
try:
|
||||||
|
head_time = subprocess.check_output(['git', 'log', '--pretty=format:%at',
|
||||||
|
'-n', '1']).strip()
|
||||||
|
dist_time = os.path.getmtime(os.path.join(SOURCE_ROOT, 'atom-shell.zip'))
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno != errno.ENOENT:
|
||||||
|
raise
|
||||||
|
return False
|
||||||
|
|
||||||
|
return dist_time > int(head_time)
|
||||||
|
|
||||||
|
|
||||||
def upload():
|
def upload():
|
||||||
os.chdir(SOURCE_ROOT)
|
os.chdir(SOURCE_ROOT)
|
||||||
bucket, access_key, secret_key = s3_config()
|
bucket, access_key, secret_key = s3_config()
|
||||||
|
|
Loading…
Reference in a new issue