|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 |
|
3 |
| -"""Manage site and releases. |
| 3 | +"""Make a release. |
4 | 4 |
|
5 | 5 | Usage:
|
6 |
| - manage.py release [<branch>] |
7 |
| - manage.py site |
| 6 | + release.py [<branch>] |
8 | 7 |
|
9 | 8 | For the release command $FMT_TOKEN should contain a GitHub personal access token
|
10 | 9 | obtained from https://github.com/settings/tokens.
|
|
13 | 12 | from __future__ import print_function
|
14 | 13 | import datetime, docopt, errno, fileinput, json, os
|
15 | 14 | import re, shutil, sys
|
16 |
| -from contextlib import contextmanager |
17 | 15 | from subprocess import check_call
|
18 | 16 | import urllib.request
|
19 | 17 |
|
@@ -82,46 +80,15 @@ class Env:
|
82 | 80 | return env
|
83 | 81 |
|
84 | 82 |
|
85 |
| -fmt_repo_url = 'git@github.com:fmtlib/fmt' |
86 |
| - |
87 |
| - |
88 |
| -def update_site(env): |
89 |
| - env.fmt_repo.update(fmt_repo_url) |
90 |
| - |
91 |
| - doc_repo = Git(os.path.join(env.build_dir, 'fmt.dev')) |
92 |
| - doc_repo.update('git@github.com:fmtlib/fmt.dev') |
93 |
| - |
94 |
| - version = '11.0.0' |
95 |
| - clean_checkout(env.fmt_repo, version) |
96 |
| - target_doc_dir = os.path.join(env.fmt_repo.dir, 'doc') |
97 |
| - |
98 |
| - # Build the docs. |
99 |
| - html_dir = os.path.join(env.build_dir, 'html') |
100 |
| - if os.path.exists(html_dir): |
101 |
| - shutil.rmtree(html_dir) |
102 |
| - include_dir = env.fmt_repo.dir |
103 |
| - import build |
104 |
| - build.build_docs(version, doc_dir=target_doc_dir, |
105 |
| - include_dir=include_dir, work_dir=env.build_dir) |
106 |
| - shutil.rmtree(os.path.join(html_dir, '.doctrees')) |
107 |
| - # Copy docs to the website. |
108 |
| - version_doc_dir = os.path.join(doc_repo.dir, version) |
109 |
| - try: |
110 |
| - shutil.rmtree(version_doc_dir) |
111 |
| - except OSError as e: |
112 |
| - if e.errno != errno.ENOENT: |
113 |
| - raise |
114 |
| - shutil.move(html_dir, version_doc_dir) |
115 |
| - |
116 |
| - |
117 |
| -def release(args): |
| 83 | +if __name__ == '__main__': |
| 84 | + args = docopt.docopt(__doc__) |
118 | 85 | env = create_build_env()
|
119 | 86 | fmt_repo = env.fmt_repo
|
120 | 87 |
|
121 | 88 | branch = args.get('<branch>')
|
122 | 89 | if branch is None:
|
123 | 90 | branch = 'master'
|
124 |
| - if not fmt_repo.update('-b', branch, fmt_repo_url): |
| 91 | + if not fmt_repo.update('-b', branch, 'git@github.com:fmtlib/fmt'): |
125 | 92 | clean_checkout(fmt_repo, branch)
|
126 | 93 |
|
127 | 94 | # Update the date in the changelog and extract the version and the first
|
@@ -217,11 +184,5 @@ def release(args):
|
217 | 184 | raise Exception(f'Failed to upload an asset '
|
218 | 185 | '{response.status} {response.reason}')
|
219 | 186 |
|
220 |
| - update_site(env) |
221 |
| - |
222 |
| -if __name__ == '__main__': |
223 |
| - args = docopt.docopt(__doc__) |
224 |
| - if args.get('release'): |
225 |
| - release(args) |
226 |
| - elif args.get('site'): |
227 |
| - update_site(create_build_env()) |
| 187 | + short_version = '.'.join(version.split('.')[:-1]) |
| 188 | + check_call(['./mkdocs', 'deploy', short_version]) |
0 commit comments