<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Release of hammer-cli gem
Requirements
push access to https
Step1:  Update the following notebook settings
Step2:  Ensure the repo is up to date
Step3:  Cherry picks for minor release
Step4:  Run tests localy
Step5:  Update release related stuff
Step6:  Manual step
Step7:  Commit changes
Step8:  Update translations
Step9:  Tag new version
Step10:  Prepare stable branch for major release
Step11:  Build the gem
Step12:  Bump the develop version for major release
Step13:  PUSH the changes upstream If everything is correct
Step14:  Now the new release is in upstream repo
Some manual steps follow to improve the UX
New relase on GitHub
Copy the following changelog lines to the description in form on link below
The release title is the new version.
<ASSISTANT_TASK:>
Python Code:
%cd ..
Explanation: Release of hammer-cli gem
Requirements
push access to https://github.com/theforeman/hammer-cli
push access to rubygems.org for hammer-cli
sudo yum install transifex-client python-slugify asciidoc
ensure neither the 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 
to push translations you need an account on Transifex (https://docs.transifex.com/client/client-configuration#~/-transifexrc)
Release process
Follow the steps with &lt;Shift&gt;+&lt;Enter&gt; or &lt;Ctrl&gt;+&lt;Enter&gt;,&lt;Down&gt;
If anything fails, fix it and re-run the step if applicable
Release settings
End of explanation
NEW_VERSION = '3.0.0'
LAST_VERSION = '2.5.1'
DEVELOP_VERSION = '2.6.0-develop'
NEXT_FUTURE_VERSION = '3.0.0'
MAJOR_RELEASE = True
STABLE_BRANCH = '2.5-stable'
GIT_REMOTE_UPSTREAM = 'origin'
WORK_BRANCH = 'master' if MAJOR_RELEASE else STABLE_BRANCH
CHERRY_PICKS = []
Explanation: Update the following notebook settings
End of explanation
! git checkout {WORK_BRANCH}
! git fetch {GIT_REMOTE_UPSTREAM}
! git rebase {GIT_REMOTE_UPSTREAM}/{WORK_BRANCH}
Explanation: Ensure the repo is up to date
End of explanation
if not MAJOR_RELEASE:
    for cp in CHERRY_PICKS:
        ! git cherry-pick -x {cp}
Explanation: Cherry picks for minor release
End of explanation
! bundle update
! bundle exec rake test
Explanation: Run tests localy
End of explanation
! sed -i 's/Gem::Version.new .*/Gem::Version.new "{NEW_VERSION}"/' lib/hammer_cli/version.rb
# 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))
# 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()  
Explanation: Update release related stuff
End of explanation
! git add -u
! git status
! git diff --cached
Explanation: Manual step: Update deps in the gemspec if neccessary
Check what is going to be commited
End of explanation
! git commit -m "Bump to {NEW_VERSION}"
Explanation: Commit changes
End of explanation
if MAJOR_RELEASE:
    ! make -C locale/ tx-update
Explanation: Update translations
End of explanation
! git tag {NEW_VERSION}
Explanation: Tag new version
End of explanation
if MAJOR_RELEASE:
    ! git checkout -b {STABLE_BRANCH}
    ! git push {GIT_REMOTE_UPSTREAM} {STABLE_BRANCH}
    ! git checkout {WORK_BRANCH}
Explanation: Prepare stable branch for major release
End of explanation
! rake build
! gem push pkg/hammer_cli-{NEW_VERSION}.gem
Explanation: Build the gem
End of explanation
if MAJOR_RELEASE:
    ! sed -i 's/Gem::Version.new .*/Gem::Version.new "{DEVELOP_VERSION}"/' lib/hammer_cli/version.rb
if MAJOR_RELEASE:
    ! git add -u
    ! git status
if MAJOR_RELEASE:
    ! git diff --cached
if MAJOR_RELEASE:
    ! git commit -m "Bump to {DEVELOP_VERSION}"
Explanation: Bump the develop version for major release
End of explanation
! git push {GIT_REMOTE_UPSTREAM} {WORK_BRANCH}
! git push --tags {GIT_REMOTE_UPSTREAM} {WORK_BRANCH}
Explanation: PUSH the changes upstream If everything is correct
End of explanation
print('\n')
print('\n'.join(change_log))
print('\n\nhttps://github.com/theforeman/hammer-cli/releases/new?tag=%s' % NEW_VERSION)
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))
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)
Explanation: Now the new release is in upstream repo
Some manual steps follow to improve the UX
New relase on GitHub
Copy the following changelog lines to the description in form on link below
The release title is the new version.
End of explanation
<END_TASK>