def import_translations(parser): source_lang = parser.get('macdown.macdownxliff', 'source_lang') xliff_dirpath = os.path.dirname( parser.get('macdown.macdownxliff', 'file_filter'), ) for fn in os.listdir(xliff_dirpath): stem, ext = os.path.splitext(fn) if ext != '.xliff' or stem == source_lang: continue logger.info('Importing {}'.format(fn)) execute( XCODEBUILD, '-importLocalizations', '-localizationPath', os.path.join(xliff_dirpath, fn), )
def main(): if os.getenv('TRAVIS_PULL_REQUEST') != 'false': print('Build triggered by a pull request. Transifex push skipped.', file=sys.stderr) return current_branch = os.getenv('TRAVIS_BRANCH') target_branch = 'master' if current_branch != target_branch: print('Branch {cur} is not {target}. Transifex push skipped.'.format( cur=current_branch, target=target_branch, ), file=sys.stderr) return clean_xliff() write_transifex_config() execute(os.path.expanduser('~/Library/Python/2.7/bin/tx'), 'push', '-s')
def main(): if os.getenv('TRAVIS_PULL_REQUEST') != 'false': print('Build triggered by a pull request. Transifex push skipped.', file=sys.stderr) return current_branch = os.getenv('TRAVIS_BRANCH') target_branch = 'master' if current_branch != target_branch: print('Branch {cur} is not {target}. Transifex push skipped.'.format( cur=current_branch, target=target_branch, ), file=sys.stderr) return write_transifex_config() execute(os.path.expanduser('~/Library/Python/2.7/bin/tx'), 'push', '-s')
def main(argv): if len(argv) < 2: name = os.path.basename(argv[0]) print('Usage: {name} private_key'.format(name=name)) return cert_path = argv[1] print('Pre-build cleaning...') if os.path.exists(BUILD_DIR): try: shutil.rmtree(BUILD_DIR) except OSError: pass if not os.path.exists(BUILD_DIR): os.mkdir(BUILD_DIR) execute( XCODEBUILD, 'clean', '-workspace', 'MacDown.xcworkspace', '-scheme', 'MacDown', ) print('Running external scripts...') os.chdir(os.path.join(ROOT_DIR, 'Dependency', 'peg-markdown-highlight')) execute('make') print('Building application archive...') os.chdir(BUILD_DIR) output = execute( XCODEBUILD, 'archive', '-workspace', '../MacDown.xcworkspace', '-scheme', 'MacDown', ) if isinstance(output, bytes): output = output.decode(TERM_ENCODING) match = re.search( r'^\s*ARCHIVE_PATH: (.+)$', output, re.MULTILINE, ) archive_path = match.group(1) print('Exporting application bundle...') execute( XCODEBUILD, '-exportArchive', '-exportFormat', 'app', '-archivePath', archive_path, '-exportPath', APP_NAME, ) # Zip. with zipfile.ZipFile(ZIP_NAME, 'w') as f: archive_dir(f, APP_NAME) input('Build finished. Press Return to display bundle information and ' 'reveal ZIP archive.') print() print('DSA signature:') command = ('{openssl} dgst -sha1 -binary < "{zip_name}" | ' '{openssl} dgst -dss1 -sign "{cert}" | ' '{openssl} enc -base64').format(openssl=OPENSSL, zip_name=ZIP_NAME, cert=cert_path) os.system(command) print() print_value('Archive size', os.path.getsize(ZIP_NAME)) with open(os.path.join(APP_NAME, 'Contents', 'Info.plist')) as plist: tree = ElementTree.parse(plist) root = tree.getroot() for infodict in root: has_key = None for child in infodict: if has_key == 'CFBundleVersion': bundle_version = child.text has_key = None elif has_key == 'CFBundleShortVersionString': short_version = child.text has_key = None elif child.tag == 'key': has_key = child.text print_value('Bundle version', bundle_version) print_value('Short version', short_version) script = 'tell application "Finder" to reveal POSIX file "{zip}"'.format( zip=os.path.abspath(ZIP_NAME)) execute(OSASCRIPT, '-e', script)
def main(argv): if len(argv) < 2: name = os.path.basename(argv[0]) print('Usage: {name} private_key'.format(name=name)) return cert_path = argv[1] print('Pre-build cleaning...') if os.path.exists(BUILD_DIR): try: shutil.rmtree(BUILD_DIR) except OSError: pass if not os.path.exists(BUILD_DIR): os.mkdir(BUILD_DIR) execute( XCODEBUILD, 'clean', '-workspace', 'MacDown.xcworkspace', '-scheme', 'MacDown', ) print('Running external scripts...') os.chdir(os.path.join(ROOT_DIR, 'Dependency', 'peg-markdown-highlight')) execute('make') print('Building application archive...') os.chdir(BUILD_DIR) output = execute( XCODEBUILD, 'archive', '-workspace', '../MacDown.xcworkspace', '-scheme', 'MacDown', ) if isinstance(output, bytes): output = output.decode(TERM_ENCODING) match = re.search( r'^\s*ARCHIVE_PATH: (.+)$', output, re.MULTILINE, ) archive_path = match.group(1) print('Exporting application bundle...') source_app_path = os.path.join( archive_path, 'Products', 'Applications', APP_NAME, ) shutil.copytree(source_app_path, APP_NAME) # Zip. with zipfile.ZipFile(ZIP_NAME, 'w') as f: archive_dir(f, APP_NAME) input( 'Build finished. Press Return to display bundle information and ' 'reveal ZIP archive.' ) print() print('DSA signature:') command = ( '{openssl} dgst -sha1 -binary < "{zip_name}" | ' '{openssl} dgst -dss1 -sign "{cert}" | ' '{openssl} enc -base64' ).format(openssl=OPENSSL, zip_name=ZIP_NAME, cert=cert_path) os.system(command) print() print_value('Archive size', os.path.getsize(ZIP_NAME)) with open(os.path.join(APP_NAME, 'Contents', 'Info.plist')) as plist: tree = ElementTree.parse(plist) root = tree.getroot() for infodict in root: has_key = None for child in infodict: if has_key == 'CFBundleVersion': bundle_version = child.text has_key = None elif has_key == 'CFBundleShortVersionString': short_version = child.text has_key = None elif child.tag == 'key': has_key = child.text print_value('Bundle version', bundle_version) print_value('Short version', short_version) script = 'tell application "Finder" to reveal POSIX file "{zip}"'.format( zip=os.path.abspath(ZIP_NAME) ) execute(OSASCRIPT, '-e', script)