Skip to content

Commit

Permalink
Add run_command to release script
Browse files Browse the repository at this point in the history
  • Loading branch information
abn290 committed Nov 19, 2017
1 parent 972b747 commit 4bd9c72
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions build/release/make_munkireport_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def set_version(version):
def get_version_from_string(str):
return str.split(" ", 1)[0]

def run_command(cmd):
print ' '.join(cmd)
subprocess.check_call(cmd)

def main():
"""Builds and pushes a new munkireport-php release from an existing Git clone
of munkireport-php.
Expand Down Expand Up @@ -155,15 +159,15 @@ def main():
changelog_path = os.path.join(munkireport_root, 'CHANGELOG.md')

# clone Git master
subprocess.check_call(
run_command(
['git', 'clone', #'--depth', '1',
'https://github.com/%s/%s' % (publish_user, publish_repo),
munkireport_root])
os.chdir(munkireport_root)

branch = 'wip'

subprocess.check_call(['git', 'checkout', branch])
run_command(['git', 'checkout', branch])

# get the current munkireport-php version
current_version = get_version()
Expand Down Expand Up @@ -198,13 +202,13 @@ def main():
fdesc.write(new_changelog)

# commit and push the new release
subprocess.check_call(['git', 'add', changelog_path])
subprocess.check_call(
run_command(['git', 'add', changelog_path])
run_command(
['git', 'commit', '-m', 'Release version %s.' % current_version])
subprocess.check_call(['git', 'tag', tag_name])
run_command(['git', 'tag', tag_name])
if not opts.dry_run:
subprocess.check_call(['git', 'push', 'origin', branch])
subprocess.check_call(['git', 'push', '--tags', 'origin', branch])
run_command(['git', 'push', 'origin', branch])
run_command(['git', 'push', '--tags', 'origin', branch])

# extract release notes for this new version
notes_rex = r"(?P<current_ver_notes>\#\#\# \[%s\].+?)\#\#\#" % current_version
Expand All @@ -214,22 +218,20 @@ def main():
release_notes = match.group('current_ver_notes')

# install dependencies
subprocess.check_call(['composer', 'install', '--no-dev',
run_command(['composer', 'install', '--no-dev',
'--ignore-platform-reqs', '--optimize-autoloader'])

# also install all suggested packages
data = json.load(open('composer.json'))
for key, value in data['suggest'].iteritems():
version = get_version_from_string(value)
pkg = "%s:%s" % (key, version)
print ['composer', 'require', '--update-no-dev',
'--ignore-platform-reqs', '--optimize-autoloader', pkg]
subprocess.check_call(['composer', 'require', '--update-no-dev',
run_command(['composer', 'require', '--update-no-dev',
'--ignore-platform-reqs', '--optimize-autoloader', pkg])

# zip up
zip_file = 'munkireport-%s.zip' % current_version
subprocess.check_call(['zip', '-r', zip_file, '.', '--exclude', '.git*'])
run_command(['zip', '-r', zip_file, '.', '--exclude', '.git*'])
with open(zip_file, 'rb') as fdesc:
zip_data = fdesc.read()

Expand Down Expand Up @@ -288,12 +290,12 @@ def main():
fdesc.write(new_changelog)

# commit and push increment
subprocess.check_call(['git', 'add', get_version_file_path(), changelog_path])
subprocess.check_call(
run_command(['git', 'add', get_version_file_path(), changelog_path])
run_command(
['git', 'commit', '-m',
'Bumping to v%s for development.' % next_version])
if not opts.dry_run:
subprocess.check_call(['git', 'push', 'origin', branch])
run_command(['git', 'push', 'origin', branch])
else:
print ("Ended dry-run mode. Final state of the munkireport-php repo can be "
"found at: %s" % munkireport_root)
Expand Down

0 comments on commit 4bd9c72

Please sign in to comment.