git push or gem push don't require interractive auth. If you can't use api key or ssh key to auth skip these steps and run them form the shell manually <Shift>+<Enter> or <Ctrl>+<Enter>,<Down>
In [ ]:
%cd ..
In [ ]:
NEW_VERSION = '2.1.1'
LAST_VERSION = '2.1.0'
DEVELOP_VERSION = '2.2.0-develop'
NEXT_FUTURE_VERSION = '2.2.0'
MAJOR_RELEASE = False
STABLE_BRANCH = '2.1-stable'
GIT_REMOTE_UPSTREAM = 'upstream'
WORK_BRANCH = 'master' if MAJOR_RELEASE else STABLE_BRANCH
In [ ]:
! git checkout {WORK_BRANCH}
In [ ]:
! git fetch {GIT_REMOTE_UPSTREAM}
In [ ]:
! git rebase {GIT_REMOTE_UPSTREAM}/{WORK_BRANCH}
In [ ]:
! bundle update
In [ ]:
! bundle exec rake test
In [ ]:
! sed -i 's/Gem::Version.new .*/Gem::Version.new "{NEW_VERSION}"/' lib/hammer_cli/version.rb
In [ ]:
# Parse git changelog
from IPython.display import Markdown as md
from subprocess import check_output
from shlex import split
import re
def format_log_entry(entry):
issues = re.findall(r'[^(]#([0-9]+)', entry)
entry = re.sub(r'([fF]ixes|[rR]efs)[^-]*-\s*(.*)', r'\2', entry)
entry = '* ' + entry.capitalize()
entry = re.sub(r'\(#([0-9]+)\)', r'([PR #\1](https://github.com/theforeman/hammer-cli/pull/\1))', entry)
for i in issues:
referenced_issues.append(i)
entry = entry + ', [#%s](http://projects.theforeman.org/issues/%s)' % (i, i)
return entry
def skip(entry):
if re.match(r'Merge pull', entry) or \
re.match(r'^i18n', entry) or \
re.match(r'^Bump to version', entry):
return True
else:
return False
referenced_issues = []
git_log_cmd = 'git log --pretty=format:"%%s" %s..HEAD' % LAST_VERSION
log = check_output(split(git_log_cmd)).decode('utf8').split('\n')
change_log = [format_log_entry(e) for e in log if not skip(e)]
md('\n'.join(change_log))
In [ ]:
# Write release notes
from datetime import datetime
import fileinput
import sys
fh = fileinput.input('doc/release_notes.md', inplace=True)
for line in fh:
print(line.rstrip())
if re.match(r'========', line):
print('### %s (%s)' % (NEW_VERSION, datetime.today().strftime('%Y-%m-%d')))
for entry in change_log:
print(entry)
print('')
fh.close()
In [ ]:
! git add -u
! git status
In [ ]:
! git diff --cached
In [ ]:
! git commit -m "Bump to {NEW_VERSION}"
In [ ]:
if MAJOR_RELEASE:
! make -C locale/ tx-update
In [ ]:
! git tag {NEW_VERSION}
In [ ]:
if MAJOR_RELEASE:
! git checkout -b {STABLE_BRANCH}
! git push {GIT_REMOTE_UPSTREAM} {STABLE_BRANCH}
! git checkout {WORK_BRANCH}
In [ ]:
! rake build
In [ ]:
! gem push pkg/hammer_cli-{NEW_VERSION}.gem
In [ ]:
if MAJOR_RELEASE:
! sed -i 's/Gem::Version.new .*/Gem::Version.new "{DEVELOP_VERSION}"/' lib/hammer_cli/version.rb
In [ ]:
if MAJOR_RELEASE:
! git add -u
! git status
In [ ]:
if MAJOR_RELEASE:
! git diff --cached
In [ ]:
if MAJOR_RELEASE:
! git commit -m "Bump to {DEVELOP_VERSION}"
In [ ]:
! git push {GIT_REMOTE_UPSTREAM} {WORK_BRANCH}
In [ ]:
! git push --tags {GIT_REMOTE_UPSTREAM} {WORK_BRANCH}
In [ ]:
print('\n')
print('\n'.join(change_log))
print('\n\nhttps://github.com/theforeman/hammer-cli/releases/new?tag=%s' % NEW_VERSION)
In [ ]:
from IPython.display import Markdown as md
md('### Create new hammer-cli release in Redmine \n' + \
'<a href="https://projects.theforeman.org/projects/hammer-cli/versions/new" target="_blank">https://projects.theforeman.org/projects/hammer-cli/versions/new</a>\n\n' + \
'Set name to hammer-cli-%s' % (NEXT_FUTURE_VERSION if MAJOR_RELEASE else NEW_VERSION))
In [ ]:
if not MAJOR_RELEASE:
print('Set fixed in versions to %s in following issues:' % NEW_VERSION)
for i in referenced_issues:
print('- https://projects.theforeman.org/issues/%s' % i)