def commit_release_branch(branch_name, version_string, internal=False): """Creates an optionally tagged release commit on the given branch.""" # Commit to the private repo with the version number commit_all_changes(branch_name, "Release: version {}".format(version_string)) if not internal: # Tag private repo with version number os_helper.call('git tag -f -a "v{}" -m "Version: {}"'.format( version_string, version_string))
def make_build_scripts_use_public_sdks(branch_name): """Changes the value of INTERNAL_SDK in the build scripts to false""" internal_sdk_line_pattern = re.compile(r':.*INTERNAL_SDK:=.*') replacement = r': "${INTERNAL_SDK:=false}"' replace_file_lines(ANDROID_BUILD_SCRIPT, (internal_sdk_line_pattern, replacement)) replace_file_lines(IOS_BUILD_SCRIPT, (internal_sdk_line_pattern, replacement)) # Reclaim execute permissions lost in replace_file_lines os_helper.call("chmod +x {}".format(ANDROID_BUILD_SCRIPT)) os_helper.call("chmod +x {}".format(IOS_BUILD_SCRIPT)) # Remove all 'mopub_*' symbols from sample app's defines, so that the corresponding # options are disabled by default. define_pattern = re.compile(r'(\s*\d+:\s*)(.*)') replace_file_lines(SAMPLE_APP_PROJECT_SETTINGS, (define_pattern, clear_mopub_defines))
def prepare_public_repo(public_repo, staging_dir): """Sets up the public repo to stage the next release. Copies the git history to a safe space, then cleans out the directory. """ cwd = os.getcwd() os.chdir(public_repo) # remember what things used to be like os_helper.call('git checkout master') os_helper.call('git pull') os_helper.call('cp -r .git {}'.format(staging_dir)) os.chdir(cwd)
def cherry_pick_to_master(branch_name): """Cherry picks the last commit from the given branch onto master.""" os_helper.call('git checkout master') os_helper.call('git cherry-pick -x --allow-empty {}'.format(branch_name)) os_helper.call('git checkout -')
def commit_public_release(version_string): """Commits the release on the local public repo, ready for push to origin.""" os_helper.call('git add -A .') commit_all_changes("master", "Release: version {}".format(version_string)) os_helper.call('git tag -f -a "v{}" -m "Version: {}"'.format( version_string, version_string))
def remove_unreleased_code(): """Remove all the code directories that we shouldn't package in the release.""" os_helper.call('rm -rf scripts/private') os_helper.call( 'find . -name *.aar* -not -path "/mopub-android-sdk/*" -delete') os_helper.call('find . -name unity*.jar -delete') os_helper.call('find . -name chartboost*.jar -delete') os_helper.call('find . -name dagger*.jar -delete') os_helper.call('find . -name javax.inject*.jar -delete') os_helper.call('find . -name vungle*.jar -delete')
def remove_internal_submodules(branch_name): """Removes and deletes submodules for internal Android and iOS SDKs""" os_helper.call('git rm -f mopub-android') os_helper.call('git rm -f mopub-ios')
def fix_git_history(public_repo, staging_dir): """Restores the git history that was copied into the given staging directory.""" os_helper.call('rm -rf {}/.git'.format(public_repo)) os_helper.call('cp -r {}/.git {}'.format(staging_dir, public_repo))
def copy_release_branch_to(branch_name, public_repo): """Copies the tagged release branch to the given directory.""" os_helper.call('rsync -aWL --delete . {}'.format(public_repo))
def push_private_release_branch(branch_name, version_string, internal=False): """Push the release branch to the private mopub_unity repo.""" os_helper.call('git push origin {}'.format(branch_name)) if not internal: # Push the release tag. os_helper.call('git push --force origin v{}'.format(version_string))
def __exit__(self, type, value, traceback): os_helper.call("rm -rf {}".format(self.direc))
def merge(branch): print 'Merging branch: {} into {}'.format(branch, current_branch()) os_helper.call('git merge {} --no-edit'.format(branch))
def pull(): print 'Pulling branch: ' + current_branch() os_helper.call('git pull')
def checkout(branch): if branch != current_branch(): print 'Checking out branch: ' + branch os_helper.call('git checkout ' + branch)