def release(): """Release/publish the code. """ # Rebase and push the master with tags to origin. print("Here are the remaining TODO items:") print(bash('TODO.sh')) print() if not util.yes("Do you still want to rebase and push the master with tags " "to origin (y/n)?"): util.delayed_exit() git.rebase('-i', 'origin/master') git.push('--tags', 'origin', 'master') # Upload to PyPI. if not util.yes("Do you want to upload to PyPI (this is permanent!) " "(y/n)?"): util.delayed_exit() setup.sdist.upload() # Reset the version number. # In natu/__init__.py: set_version('None') # In CHANGES.txt: newheading = ('TBD (in `GitHub <https://github.com/kdavies4/natu>`_ ' 'only) -- Updates:') newlink = ('.. _vx.x.x: ' 'https://github.com/kdavies4/natu/archive/vx.x.x.zip') rpls = [(r'(<http://semver.org>`_\.)', r'\1\n\n' + newheading), (r'(Initial release\n\n\n)', r'\1%s\n' % newlink)] util.replace('CHANGES.txt', rpls)
def html(): """Build/make the HTML documentation. """ # Rebuild the static images. if util.yes("Do you want to rebuild the static images (y/n)?"): static() # Update the download link. try: commit = git('rev-list', '--tags', '--max-count=1').stdout.rstrip() lastversion = git.describe('--tags', commit).stdout.rstrip() # This is simpler but doesn't always return the latest tag: # lastversion = git.describe('--tag', abbrev=0).stdout.rstrip() except ErrorReturnCode_128: pass # No tags recorded; leave download link as is else: date = git.log('-1', lastversion, date='short', format='%ad').stdout[8:18] rpls = [(r'(ModelicaRes)-.*(\.tar)', r'\1-%s\2' % lastversion[1:]), (r'(Latest version<br>\().*(\)</a>)', r'\1%s, %s\2' % (lastversion, date)), ] util.replace('_templates/download.html', rpls) # Build the documentation. make_dirs() sphinx = sphinx_build.bake(b='html', d='build/doctrees') print(sphinx('.', BUILD_DIR)) # Spellcheck. if util.yes("Do you want to spellcheck the HTML documentation (y/n)?"): spellcheck()
def release(): """Release/publish the code. """ # Rebase and push the master with tags to origin. print("Here are the remaining TODO items:") print(bash('TODO.sh')) print() if not util.yes( "Do you still want to rebase and push the master with tags " "to origin (y/n)?"): util.delayed_exit() git.rebase('-i', 'origin/master') git.push('--tags', 'origin', 'master') # Upload to PyPI. if not util.yes("Do you want to upload to PyPI (this is permanent!) " "(y/n)?"): util.delayed_exit() setup.sdist.upload() # Reset the version number. # In CHANGES.txt: newheading = ('TBD (in `GitHub <https://github.com/kdavies4/natu>`_ ' 'only) -- Updates:') newlink = ('.. _vx.x.x: ' 'https://github.com/kdavies4/natu/archive/vx.x.x.zip') rpls = [(r'(<http://semver.org>`_\.)', r'\1\n\n' + newheading), (r'(Initial release\n\n\n)', r'\1%s\n' % newlink)] util.replace('CHANGES.txt', rpls)
def html(): """Build/make the HTML documentation. """ # Rebuild the static images. if util.yes("Do you want to rebuild the static images (y/n)?"): static() # Update the download link. try: commit = git('rev-list', '--tags', '--max-count=1').stdout.rstrip() lastversion = git.describe('--tags', commit).stdout.rstrip() # This is simpler but doesn't always return the latest tag: # lastversion = git.describe('--tag', abbrev=0).stdout.rstrip() except ErrorReturnCode_128: pass # No tags recorded; leave download link as is else: date = git.log('-1', lastversion, date='short', format='%ad').stdout[8:18] rpls = [ (r'(ModelicaRes)-.*(\.tar)', r'\1-%s\2' % lastversion[1:]), (r'(Latest version<br>\().*(\)</a>)', r'\1%s, %s\2' % (lastversion, date)), ] util.replace('_templates/download.html', rpls) # Build the documentation. make_dirs() sphinx = sphinx_build.bake(b='html', d='build/doctrees') print((sphinx('.', BUILD_DIR))) # Spellcheck. if util.yes("Do you want to spellcheck the HTML documentation (y/n)?"): spellcheck()
def release(): """Release/publish the documentation to the webpage. """ # Save the current state. branch = git('rev-parse', '--abbrev-ref', 'HEAD').stdout.rstrip() git.stash('save', "Work in progress while updating gh-pages branch") # Check out the gh-pages branch. try: git.checkout('gh-pages') except ErrorReturnCode_128: # Create the branch if necessary. git.checkout('-b', 'gh-pages') # Remove the existing files in the base folder. extensions = ['*.html', '*.inv'] fnames = util.multiglob('..', extensions) for fname in fnames: os.remove(fname) # Copy the new files to the base folder. fnames = util.multiglob(BUILD_DIR, extensions) for fname in fnames: shutil.copy(fname, '..') # Track the new files. fnames = util.multiglob('..', extensions) git.add(*fnames) # Copy but rename the folders referenced in the HTML files. # Github only recognizes images, stylesheets, and javascripts as folders. folders = [('_images', 'images'), ('_static', 'javascripts'), ] for (src, dst) in folders: dst = os.path.join('..', dst) # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new folder. shutil.copytree(os.path.join(BUILD_DIR, src), dst) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. html_fnames = glob(os.path.join('..', '*.html')) util.replace(html_fnames, folders) # Copy and rename the examples folder. src = os.path.join(BUILD_DIR, 'examples') dst = '../examples2' # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new files. os.mkdir(dst) for fname in os.listdir(src): shutil.copy(os.path.join(src, fname), os.path.join(dst, fname)) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. util.replace(html_fnames, [(r'"\./examples/', r'"./examples2/')]) # Update the sitemap. print(python('sitemap_gen.py', config="sitemap_conf.xml")) # Commit the changes. try: git.commit('-a', m="Rebuilt documentation") except ErrorReturnCode_1: pass # No changes to commit # If desired, rebase and push the changes to origin. print("The gh-pages branch has been updated and is currently checked out.") if util.yes("Do you want to rebase it and push the changes to " "origin (y/n)?"): git.rebase('-i', 'origin/gh-pages') git.push.origin('gh-pages') # Return to the original state. git.checkout(branch) try: git.stash.pop() except ErrorReturnCode_1: pass # No stash was necessary in the first place. print("Now back on " + branch)
def release(): """Release/publish the documentation to the webpage. """ # Save the current state. branch = git('rev-parse', '--abbrev-ref', 'HEAD').stdout.rstrip() git.stash('save', "Work in progress while updating gh-pages branch") # Check out the gh-pages branch. try: git.checkout('gh-pages') except ErrorReturnCode_128: # Create the branch if necessary. git.checkout('-b', 'gh-pages') # Remove the existing files in the base folder. extensions = ['*.html', '*.inv'] fnames = util.multiglob('..', extensions) for fname in fnames: os.remove(fname) # Copy the new files to the base folder. fnames = util.multiglob(BUILD_DIR, extensions) for fname in fnames: shutil.copy(fname, '..') # Track the new files. fnames = util.multiglob('..', extensions) git.add(*fnames) # Copy but rename the folders referenced in the HTML files. # Github only recognizes images, stylesheets, and javascripts as folders. folders = [ ('_images', 'images'), ('_static', 'javascripts'), ] for (src, dst) in folders: dst = os.path.join('..', dst) # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new folder. shutil.copytree(os.path.join(BUILD_DIR, src), dst) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. html_fnames = glob(os.path.join('..', '*.html')) util.replace(html_fnames, folders) # Copy and rename the examples folder. src = os.path.join(BUILD_DIR, 'examples') dst = '../examples2' # Remove the existing folder. shutil.rmtree(dst, ignore_errors=True) # Copy the new files. os.mkdir(dst) for fname in os.listdir(src): shutil.copy(os.path.join(src, fname), os.path.join(dst, fname)) # Track the new folder. git.add(dst) # Update the HTML files to reference the new folder names. util.replace(html_fnames, [(r'"\./examples/', r'"./examples2/')]) # Update the sitemap. print((python('sitemap_gen.py', config="sitemap_conf.xml"))) # Commit the changes. try: git.commit('-a', m="Rebuilt documentation") except ErrorReturnCode_1: pass # No changes to commit # If desired, rebase and push the changes to origin. print("The gh-pages branch has been updated and is currently checked out.") if util.yes("Do you want to rebase it and push the changes to " "origin (y/n)?"): git.rebase('-i', 'origin/gh-pages') git.push.origin('gh-pages') # Return to the original state. git.checkout(branch) try: git.stash.pop() except ErrorReturnCode_1: pass # No stash was necessary in the first place. print(("Now back on " + branch))