mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-22 15:39:50 +00:00
Update the release script
This commit is contained in:
parent
0e8aad961d
commit
3c8aad8df7
@ -1,10 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Manage site and releases.
|
||||
"""Make a release.
|
||||
|
||||
Usage:
|
||||
manage.py release [<branch>]
|
||||
manage.py site
|
||||
release.py [<branch>]
|
||||
|
||||
For the release command $FMT_TOKEN should contain a GitHub personal access token
|
||||
obtained from https://github.com/settings/tokens.
|
||||
@ -13,7 +12,6 @@ obtained from https://github.com/settings/tokens.
|
||||
from __future__ import print_function
|
||||
import datetime, docopt, errno, fileinput, json, os
|
||||
import re, shutil, sys
|
||||
from contextlib import contextmanager
|
||||
from subprocess import check_call
|
||||
import urllib.request
|
||||
|
||||
@ -82,46 +80,15 @@ def create_build_env():
|
||||
return env
|
||||
|
||||
|
||||
fmt_repo_url = 'git@github.com:fmtlib/fmt'
|
||||
|
||||
|
||||
def update_site(env):
|
||||
env.fmt_repo.update(fmt_repo_url)
|
||||
|
||||
doc_repo = Git(os.path.join(env.build_dir, 'fmt.dev'))
|
||||
doc_repo.update('git@github.com:fmtlib/fmt.dev')
|
||||
|
||||
version = '11.0.0'
|
||||
clean_checkout(env.fmt_repo, version)
|
||||
target_doc_dir = os.path.join(env.fmt_repo.dir, 'doc')
|
||||
|
||||
# Build the docs.
|
||||
html_dir = os.path.join(env.build_dir, 'html')
|
||||
if os.path.exists(html_dir):
|
||||
shutil.rmtree(html_dir)
|
||||
include_dir = env.fmt_repo.dir
|
||||
import build
|
||||
build.build_docs(version, doc_dir=target_doc_dir,
|
||||
include_dir=include_dir, work_dir=env.build_dir)
|
||||
shutil.rmtree(os.path.join(html_dir, '.doctrees'))
|
||||
# Copy docs to the website.
|
||||
version_doc_dir = os.path.join(doc_repo.dir, version)
|
||||
try:
|
||||
shutil.rmtree(version_doc_dir)
|
||||
except OSError as e:
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
shutil.move(html_dir, version_doc_dir)
|
||||
|
||||
|
||||
def release(args):
|
||||
if __name__ == '__main__':
|
||||
args = docopt.docopt(__doc__)
|
||||
env = create_build_env()
|
||||
fmt_repo = env.fmt_repo
|
||||
|
||||
branch = args.get('<branch>')
|
||||
if branch is None:
|
||||
branch = 'master'
|
||||
if not fmt_repo.update('-b', branch, fmt_repo_url):
|
||||
if not fmt_repo.update('-b', branch, 'git@github.com:fmtlib/fmt'):
|
||||
clean_checkout(fmt_repo, branch)
|
||||
|
||||
# Update the date in the changelog and extract the version and the first
|
||||
@ -217,11 +184,5 @@ def release(args):
|
||||
raise Exception(f'Failed to upload an asset '
|
||||
'{response.status} {response.reason}')
|
||||
|
||||
update_site(env)
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = docopt.docopt(__doc__)
|
||||
if args.get('release'):
|
||||
release(args)
|
||||
elif args.get('site'):
|
||||
update_site(create_build_env())
|
||||
short_version = '.'.join(version.split('.')[:-1])
|
||||
check_call(['./mkdocs', 'deploy', short_version])
|
Loading…
x
Reference in New Issue
Block a user