Created
August 7, 2014 07:23
-
-
Save beiliubei/ad58121fdb72b3963895 to your computer and use it in GitHub Desktop.
android || ios build script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import re | |
import yaml | |
import time | |
import shutil | |
import argparse | |
import ConfigParser | |
from os import path | |
from subprocess import check_call, check_output, CalledProcessError | |
#========================main ============================== | |
def main(origin_args): | |
parser = argparse.ArgumentParser( | |
description="This is augploy mobile build script", | |
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | |
args_repo_group = parser.add_mutually_exclusive_group() | |
args_repo_group.add_argument( | |
'-r', '--repo', default=os.getcwd(), | |
help='url of the repo to deploy, default is current working directory for quick test') | |
# parser.add_argument( | |
# '-l', | |
# help='repo file path, relative to augploy directory in the repo to deploy') | |
parser.add_argument( | |
'repo_file', | |
help='repo file path, relative to augploy directory in the repo to deploy') | |
args = parser.parse_known_args(origin_args) | |
repo_config = load_yml_file("%s/%s" % (args[0].repo, args[0].repo_file)) | |
if repo_config['device'] in "Android": | |
log("===== use gradle =====") | |
executeAndroidBuild(repo_config) | |
pass | |
elif repo_config['device'] in "ios": | |
log("===== use xcode =====") | |
executeIosBuild(repo_config) | |
def executeAndroidBuild(repoConfig): | |
repo_url = repoConfig['repoUrl'] | |
try: | |
check_output('git clone %s' % | |
(repo_url), shell=True) | |
os.chdir(repoConfig['workspace']) | |
log("===== now in " + os.getcwd() + " =====") | |
except Exception: | |
os.chdir(repoConfig['workspace']) | |
log("===== now in " + os.getcwd() + " =====") | |
log("===== git pull --rebase =====") | |
check_output('git pull --rebase', shell=True) | |
log("===== gradle clean build =====") | |
check_output('gradle clean build', shell=True) | |
pass | |
def executeIosBuild(repoConfig): | |
pass | |
# ============================= util methods =================== | |
def log(msg): | |
print(msg) | |
def load_yml_file(yml_path): | |
with open(yml_path) as yml_file: | |
return yaml.load(yml_file) | |
def makedirs(dir): | |
if not path.isdir(dir): | |
os.makedirs(dir) | |
# ============================= yml file format =================== | |
# device : Android || ios | |
# repoUrl: https://github.com/beiliubei/AndroidProgressHUD | |
# workspace : AndroidProgressHUD | |
if __name__ == '__main__': | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment