Skip to content

Commit

Permalink
added-all
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Jul 8, 2017
1 parent e793cd7 commit f4d9109
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions hack/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def check_antipackage():
import sys
from os.path import expandvars
import yaml
from collections import Counter

libbuild.REPO_ROOT = expandvars('$GOPATH') + '/src/github.com/k8sdb/cli'

Expand Down Expand Up @@ -77,6 +78,11 @@ def git_checkout(branch, cwd=libbuild.REPO_ROOT):
call('git checkout -f -B {0} origin/{0}'.format(branch), cwd=cwd)


def git_requires_commit(cwd=libbuild.REPO_ROOT):
changed_files = check_output('git diff --name-only', cwd=cwd).strip().split('\n')
return Counter(changed_files) == Counter(['glide.yaml', 'glide.lock'])


def glide_mod(glide_config, changes):
for dep in glide_config['import']:
if dep['package'] in changes:
Expand Down Expand Up @@ -114,7 +120,13 @@ def release_apimachinery(self):
print(repo)
print('----------------------------------------------------------------------------------------')
git_checkout('master', cwd=repo)
call('./hack/make.py', cwd=repo)
call('glide slow', cwd=repo)
if git_requires_commit(cwd=repo):
call('./hack/make.py', cwd=repo)
call('git commit -a -m "Prepare release {0}"'.format(self.tag), cwd=repo, eoe=False)
call('git push origin master', cwd=repo)
else:
call('git reset HEAD --hard', cwd=repo)
git_checkout(self.release_branch, cwd=repo)
call('git merge master', cwd=repo)
call('git push origin {0}'.format(self.release_branch), cwd=repo)
Expand All @@ -129,10 +141,12 @@ def release_db(self, db):
glide_mod(glide_config, self.rel_deps)
glide_write(glide_file, glide_config)
call('glide slow', cwd=repo)

call('./hack/make.py', cwd=repo)
call('git commit -a -m "Prepare release {0}"'.format(self.tag), cwd=repo, eoe=False)
call('git push origin master', cwd=repo)
if git_requires_commit(cwd=repo):
call('./hack/make.py', cwd=repo)
call('git commit -a -m "Prepare release {0}"'.format(self.tag), cwd=repo, eoe=False)
call('git push origin master', cwd=repo)
else:
call('git reset HEAD --hard', cwd=repo)
git_checkout(self.release_branch, cwd=repo)
call('git merge master', cwd=repo)
call('git tag -fa {0}'.format(self.tag), cwd=repo)
Expand Down Expand Up @@ -207,9 +221,13 @@ def release(tag=None):


if __name__ == "__main__":
if len(sys.argv) > 1:
# http://stackoverflow.com/a/834451
# http://stackoverflow.com/a/817296
release(*sys.argv[1:])
else:
print('Usage ./hack/release.py 0.3.0')
print check_output('git diff --name-only').strip().split('\n')



# if len(sys.argv) > 1:
# # http://stackoverflow.com/a/834451
# # http://stackoverflow.com/a/817296
# release(*sys.argv[1:])
# else:
# print('Usage ./hack/release.py 0.3.0')

0 comments on commit f4d9109

Please sign in to comment.