-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 @@ | |
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 @@ class Env: | |
return env | ||
|
||
|
||
fmt_repo_url = '[email protected]: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('[email protected]: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, '[email protected]: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]) |