From 3c8aad8df7d08a693f791cee3b94733d2696a33c Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 26 Dec 2024 07:03:15 -0800 Subject: [PATCH] Update the release script --- support/{manage.py => release.py} | 53 ++++--------------------------- 1 file changed, 7 insertions(+), 46 deletions(-) rename support/{manage.py => release.py} (81%) diff --git a/support/manage.py b/support/release.py similarity index 81% rename from support/manage.py rename to support/release.py index ff463e0e17be..26de7f4fd401 100755 --- a/support/manage.py +++ b/support/release.py @@ -1,10 +1,9 @@ #!/usr/bin/env python3 -"""Manage site and releases. +"""Make a release. Usage: - manage.py release [] - manage.py site + release.py [] 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 = '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('') 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])