X-Git-Url: https://dev.renevier.net/?p=syj.git;a=blobdiff_plain;f=scripts%2Frelease.py;h=a95ddd6b6a7284b8293c104f0b35ed87a37740cf;hp=95452004e31a7609899cb24a793661a5cc9a55fa;hb=7ab93faefae14af39fc5449a2c3311dd68d2c0f9;hpb=38bedcd63499189e0584bfff6e44ae4018283eb1 diff --git a/scripts/release.py b/scripts/release.py index 9545200..a95ddd6 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -5,6 +5,28 @@ __BUILD__="build" import shutil, os, sys, subprocess, tempfile, tarfile, glob, ConfigParser pathjoin = os.path.join +def updateversion(): + try: + import git + repo = git.Repo('.') + master = repo.commits()[0] + tag = (filter(lambda tag: tag.commit.id == master.id, repo.tags) or [""])[0] + if tag: + version = tag.name + except ImportError: + version = subprocess.Popen(['git', 'tag', '-l', '--contains', 'master'], stdout=subprocess.PIPE).communicate()[0][:-1] + if not version: + raise AssertionError, "master is not tagged" + + fd, fname = tempfile.mkstemp() + f = os.fdopen(fd, 'w') + versionfile = 'build/application/Version.php' + with open('build/application/Version.php') as source: + for line in source: + f.write(line.replace('$SYJVERSION$', version)) + f.close() + shutil.move(fname, versionfile) + def compress(path): tmpout = tempfile.TemporaryFile() subprocess.Popen(['yui-compressor', path], stdout=tmpout).communicate() @@ -88,6 +110,8 @@ def main(): install(source, target) + updateversion() + print "creating syj.tar.gz" targz = tarfile.open("build/syj.tar.gz", "w:gz") for path in glob.glob(pathjoin(__BUILD__, '*')):