Make sure dist is created for the HEAD before uploading.

This commit is contained in:
Cheng Zhao 2013-06-29 11:36:02 +08:00
parent 02ba7d27b9
commit 0af724205c
2 changed files with 31 additions and 0 deletions

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python
import atexit
import contextlib
import errno
import shutil
import subprocess
@ -18,6 +19,16 @@ def tempdir(prefix=''):
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):
with open(path, 'w') as local_file:
web_file = urllib2.urlopen(url)

View file

@ -4,8 +4,11 @@ import errno
import glob
import os
import subprocess
import sys
import tempfile
from lib.util import *
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():
try:
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()
except AssertionError as e:
return e.message
@ -28,6 +34,20 @@ def ensure_s3put():
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():
os.chdir(SOURCE_ROOT)
bucket, access_key, secret_key = s3_config()