mirror of
https://github.com/fmtlib/fmt.git
synced 2025-04-24 09:02:32 +00:00
Update the release script
This commit is contained in:
parent
0e8aad961d
commit
3c8aad8df7
@ -1,10 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""Manage site and releases.
|
"""Make a release.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
manage.py release [<branch>]
|
release.py [<branch>]
|
||||||
manage.py site
|
|
||||||
|
|
||||||
For the release command $FMT_TOKEN should contain a GitHub personal access token
|
For the release command $FMT_TOKEN should contain a GitHub personal access token
|
||||||
obtained from https://github.com/settings/tokens.
|
obtained from https://github.com/settings/tokens.
|
||||||
@ -13,7 +12,6 @@ obtained from https://github.com/settings/tokens.
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import datetime, docopt, errno, fileinput, json, os
|
import datetime, docopt, errno, fileinput, json, os
|
||||||
import re, shutil, sys
|
import re, shutil, sys
|
||||||
from contextlib import contextmanager
|
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
@ -82,46 +80,15 @@ def create_build_env():
|
|||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
fmt_repo_url = 'git@github.com:fmtlib/fmt'
|
if __name__ == '__main__':
|
||||||
|
args = docopt.docopt(__doc__)
|
||||||
|
|
||||||
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):
|
|
||||||
env = create_build_env()
|
env = create_build_env()
|
||||||
fmt_repo = env.fmt_repo
|
fmt_repo = env.fmt_repo
|
||||||
|
|
||||||
branch = args.get('<branch>')
|
branch = args.get('<branch>')
|
||||||
if branch is None:
|
if branch is None:
|
||||||
branch = 'master'
|
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)
|
clean_checkout(fmt_repo, branch)
|
||||||
|
|
||||||
# Update the date in the changelog and extract the version and the first
|
# 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 '
|
raise Exception(f'Failed to upload an asset '
|
||||||
'{response.status} {response.reason}')
|
'{response.status} {response.reason}')
|
||||||
|
|
||||||
update_site(env)
|
short_version = '.'.join(version.split('.')[:-1])
|
||||||
|
check_call(['./mkdocs', 'deploy', short_version])
|
||||||
if __name__ == '__main__':
|
|
||||||
args = docopt.docopt(__doc__)
|
|
||||||
if args.get('release'):
|
|
||||||
release(args)
|
|
||||||
elif args.get('site'):
|
|
||||||
update_site(create_build_env())
|
|
Loading…
x
Reference in New Issue
Block a user